Académique Documents
Professionnel Documents
Culture Documents
npr.org
Overview
Background
Database Architecture SQL Differences
Concurrency Issues
Useful MySQL Tools Encoding Gotchas
Background
Leading producer and distributor of radio programming All Things Considered, Morning Edition, Fresh Air, Wait, Wait, Dont Tell Me, etc.
Website (NPR.org) with audio content from radio programs Web-Only content including blogs, slideshows, editorial columns
Redundancy
Scalability Load balancing
Separation of concerns
Better security
Database Architecture
Content Mgmt System Main RO slave
Main Web Servers Read and updated only by our website InnoDB Low resource contention Main Updated by a nightly script Small tables or log tables RO slave Read-only by our Content Short Transactions Management System Need fast full text queries AMG STATIONS PUBLIC (replacing Oracle Text) MyISAM InnoDB InnoDB Large tables Isolation Updated from by main Content website Management System Updated by a our quarterly script Transaction Read-only by Oriented our Read-only from ourwebservers website Horizontally Resource Contention scalable Scripts Some log type information written Backup Highly Normalized Low resource contention RO slave No transactions
MySQL sorts null to the top, Oracle sorts null to the bottom
Use order by colName desc for sorting asc with nulls at bottom
For updating many rows at once, get the total number of unique IDs you need first:
Then update npr_seq by that many rows: and store that ID into another variable:
Then use the whole rownum workaround described above to get a unique value for each row:
. .
Converting Functions
NVL() -> IFNULL() or COALESCE() DECODE() -> CASE() or IF() Concatenating strings || -> CONCAT()
test || null returns test in Oracle CONCAT(test,null) returns null in MySQL Use LOCATE() for Oracles INSTR() with occurrences = 1. SUBSTRING_INDEX() and REVERSE() might also work.
Converting Dates
Update Differences
You can't update a table that is used in the WHERE clause for the update (usually in an "EXISTS" or a subselect) in mysql.
UPDATE tableA SET tableA.col1 = NULL WHERE tableA.col2 IN (SELECT tableA.col2 FROM tableA A2, tableB WHERE tableB.col3 = A2.col3 AND tableB.col4 = 123456);
Collation
Backups will use the original collation unless you specify all the way down to column level.
Concurrency Issues
Deadlocks
Slow Queries
MySQL configuration
transaction_isolation = READ-COMMITTED
Developer
MySQL Administrator
innotop
http://code.google.com/p/innotop
In mysql, use
show engine innodb status\G;
Query Profiling
query-profiler.html
Concurrency Solution
Encoding Gotchas
Lack of documentation for the LUA script produced by the migration GUI
Continuing Issues
Questions?
Joanne Garlow
jgarlow@npr.org
http://www.npr.org/blogs/inside