DBA Tales from the Front: from Oracle to  MySQL   <ul><li>Ben Krug </li></ul><ul><li>DBA, Adapt Technologies </li></ul><ul...
Who I am: <ul><li>DBA at Adapt Technologies </li></ul><ul><li>database experience (chronologically): SAS, Mumps (!), Sybas...
What I’ll talk about: <ul><li>what happened to me?  (from Oracle to MySQL) </li></ul><ul><li>Oracle gestalt vs MySQL gesta...
Slides are just an outline <ul><li>handouts have more details </li></ul><ul><li>for soft copies, email ben@adapt.com </li>...
DBA at Adapt – from Oracle to MySQL <ul><li>Accepted position looking for RAC mastery... got “Ask Tom's” book, Tales from ...
Oracle to MySQL:  from no eyebrows to eyebrows…
Q: Are the differences in their websites symptomatic? <ul><li>Oracle website (in my experience) was alway slow, confusing,...
What’s in a word? <ul><li>Terminology is different </li></ul><ul><li>(eg, schema vs tablespace vs database) </li></ul><ul>...
Differences in getting the scoop: <ul><li>Wading through Oracle PR gobbledy-gook vs having to research each item to find o...
Differences in what they are <ul><li>different products - be-all end-all vs a database </li></ul><ul><li>oracle seemed mor...
Different Philosophies? <ul><li>Open source vs closed </li></ul><ul><li>Who are they serving </li></ul><ul><li>What are th...
Different communities <ul><li>Open source community vs proprietary source community </li></ul><ul><li>Knowledge of inner-w...
Different support experiences <ul><li>Oracle - hated it </li></ul><ul><li>log a tar, if it's not severity 1, good luck get...
Different scaling strategies <ul><li>“ scaling out” vs “scaling up” </li></ul>
OK, so go get it!  <ul><li>went to mysqlab.com and downloaded community edition rpm's and installed them. </li></ul><ul><l...
Get your developer / DBA tools <ul><li>not like Oracle 10g with its instrumentation (but can set up advisors, if you pay) ...
Our first GOTCHA – storage engines <ul><li>choose a storage engine!  Eg… </li></ul><ul><li>MyISAM - default, good performa...
Scaling strategies (scaling out) <ul><li>replication configurations - master/slave </li></ul><ul><li>if you're going to us...
Set up your backups <ul><li>mysqldump (exports) </li></ul><ul><li>no hot backups for InnoDB? – linux can use LVM </li></ul...
Set up your permissions <ul><li>No roles </li></ul><ul><li>can be based on where someone is coming from (what host or subn...
Build your DB!  Issues… <ul><li>InnoDB tables are clustered by PK, other keys point to PK values </li></ul><ul><li>beware ...
Let the users in <ul><li>users' connection settings </li></ul><ul><li>@@autocomit - on by default </li></ul><ul><li>can us...
Our next GOTCHA <ul><li>collations </li></ul><ul><li>default is latin1_swedish_ci  </li></ul><ul><li>'a'='A' </li></ul><ul...
GOTCHA 3 <ul><li>autocommit=1 by default </li></ul><ul><li>wanted autocommit turned off for most code, but on for one user...
GOTCHA 3 <ul><li>autocommit=1 by default </li></ul><ul><li>wanted autocommit turned off for most code, but on for one user...
GOTCHA 3 <ul><li>autocommit=1 by default </li></ul><ul><li>wanted autocommit turned off for most code, but on for one user...
Our next GOTCHA <ul><li>SQL_MODEs -  </li></ul><ul><li>Inserting inserting bad data by default, rather than giving errors ...
GOTCHA <ul><li>error messages that are not informative or are misleading </li></ul><ul><li>eg, errors involving foreign ke...
GOTCHA <ul><li>Locks are different!  InnoDB locks... deal with it: </li></ul><ul><li>Writers blocking readers, readers blo...
GOTCHA <ul><li>using &quot;force index&quot; in a select doesn't really &quot;force&quot; the use of the index </li></ul><...
Care for your database <ul><li>GOTCHA: optimizing for an InnoDB table prevents updates </li></ul><ul><li>&quot;large&quot;...
Performance… <ul><li>performance can suffer over time for inserts and updates in large tables </li></ul><ul><li>use optimi...
So why do I love MySQL? <ul><li>you can read the code, so people know how it works (including support staff) </li></ul><ul...
And where do you go for help? <ul><li>Buy support!  It’s worth it – cheap and very useful. </li></ul><ul><li>Read the docs...
Q&A <ul><li>Ben Krug </li></ul><ul><li>DBA, Adapt Technologies </li></ul><ul><li>[email_address] </li></ul><ul><li>OSCON J...
Upcoming SlideShare
Loading in …5
×

Os Krug

691 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
691
On SlideShare
0
From Embeds
0
Number of Embeds
31
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Os Krug

  1. 1. DBA Tales from the Front: from Oracle to MySQL <ul><li>Ben Krug </li></ul><ul><li>DBA, Adapt Technologies </li></ul><ul><li>[email_address] </li></ul><ul><li>OSCON July 2007 </li></ul>
  2. 2. Who I am: <ul><li>DBA at Adapt Technologies </li></ul><ul><li>database experience (chronologically): SAS, Mumps (!), Sybase, *Oracle*, DB2, mSQL, (PostgreSQL), now MySQL </li></ul><ul><li>As a DBA, helped build an Oracle application that won a Smithsonian Award for Excellence in Computing </li></ul><ul><li>Trivia: was once in an ad for Oracle, for the same system </li></ul>
  3. 3. What I’ll talk about: <ul><li>what happened to me? (from Oracle to MySQL) </li></ul><ul><li>Oracle gestalt vs MySQL gestalt </li></ul><ul><li>gotchas (battle wounds - maybe you can learn from our mistakes) </li></ul>
  4. 4. Slides are just an outline <ul><li>handouts have more details </li></ul><ul><li>for soft copies, email ben@adapt.com </li></ul>
  5. 5. DBA at Adapt – from Oracle to MySQL <ul><li>Accepted position looking for RAC mastery... got “Ask Tom's” book, Tales from the Oak Table, CBO book by Jonathan Lewis. </li></ul><ul><li>Read in Tales from the Oak Table how when systems get heavily instrumented, it’s great, but it shows maturity, and is a sign newer systems are coming around the corner... few days later – find out my company is dropping Oracle for an open source database. </li></ul>
  6. 6. Oracle to MySQL: from no eyebrows to eyebrows…
  7. 7. Q: Are the differences in their websites symptomatic? <ul><li>Oracle website (in my experience) was alway slow, confusing, overblown </li></ul><ul><li>MySQL website relatively simple, quick, and easy </li></ul>
  8. 8. What’s in a word? <ul><li>Terminology is different </li></ul><ul><li>(eg, schema vs tablespace vs database) </li></ul><ul><li>(cheat sheet in handouts) </li></ul>
  9. 9. Differences in getting the scoop: <ul><li>Wading through Oracle PR gobbledy-gook vs having to research each item to find out about its existence or features. </li></ul><ul><li>(eg storage engines, to see what they can actually do) </li></ul>
  10. 10. Differences in what they are <ul><li>different products - be-all end-all vs a database </li></ul><ul><li>oracle seemed more complicated - RAC, interconnects, fusion, etc etc - always new pieces and teasers and mystifying PR </li></ul><ul><li>MySQL appeared more simple - a database. less confusing PR but also less documentation. (OTOH, user comments in docs.) </li></ul><ul><li>oracle - which features do you buy - DB, which components, other products (Oracle Identity, etc etc) </li></ul><ul><li>MySQL - buy (or don’t buy!) the DB </li></ul>
  11. 11. Different Philosophies? <ul><li>Open source vs closed </li></ul><ul><li>Who are they serving </li></ul><ul><li>What are they trying to achieve </li></ul><ul><li>Etc… </li></ul>
  12. 12. Different communities <ul><li>Open source community vs proprietary source community </li></ul><ul><li>Knowledge of inner-workings of DB </li></ul><ul><li>Mood of excitement with MySQL </li></ul><ul><li>Who are the customers? (web 2.0!) </li></ul><ul><li>Etc… </li></ul>
  13. 13. Different support experiences <ul><li>Oracle - hated it </li></ul><ul><li>log a tar, if it's not severity 1, good luck getting competent help if you ever hear back </li></ul><ul><li>once had to make threats to get help with a mission-critical sev 1 (Oracle v7, to be fair) </li></ul><ul><li>MySQL - love it! </li></ul><ul><li>have always had timely help, almost always very knowledgeable, helpful, and interested </li></ul><ul><li>don't need to try to get past level 1 support </li></ul>
  14. 14. Different scaling strategies <ul><li>“ scaling out” vs “scaling up” </li></ul>
  15. 15. OK, so go get it! <ul><li>went to mysqlab.com and downloaded community edition rpm's and installed them. </li></ul><ul><li>build from source if you're hardcore </li></ul>
  16. 16. Get your developer / DBA tools <ul><li>not like Oracle 10g with its instrumentation (but can set up advisors, if you pay) </li></ul><ul><li>MySQL GUI tools - MySQL Query Browser, MySQL Administrator, etc </li></ul>
  17. 17. Our first GOTCHA – storage engines <ul><li>choose a storage engine! Eg… </li></ul><ul><li>MyISAM - default, good performance, no FKs no ACID transactions </li></ul><ul><li>NDB (for clustering) - in-memory only on 5.0 </li></ul><ul><li>InnoDB - FKs and ACID-compliant transactions (InnoBase owned by Oracle now) </li></ul><ul><li>Falcon - coming... </li></ul><ul><li>etc </li></ul>
  18. 18. Scaling strategies (scaling out) <ul><li>replication configurations - master/slave </li></ul><ul><li>if you're going to use sharding, beware issues for auto_increments, FKs, global views (failures if a host fails), etc </li></ul>
  19. 19. Set up your backups <ul><li>mysqldump (exports) </li></ul><ul><li>no hot backups for InnoDB? – linux can use LVM </li></ul><ul><li>can also use mysqldumps and then binary logs to roll forward </li></ul><ul><li>(but beware statement-based vs row-based logging, especially if you use auto-increments) </li></ul>
  20. 20. Set up your permissions <ul><li>No roles </li></ul><ul><li>can be based on where someone is coming from (what host or subnet) </li></ul><ul><li>networking issues? IP-based vs name-based authentication </li></ul>
  21. 21. Build your DB! Issues… <ul><li>InnoDB tables are clustered by PK, other keys point to PK values </li></ul><ul><li>beware that FKs in InnoDB can cause locking issues (lock wait timeouts) </li></ul>
  22. 22. Let the users in <ul><li>users' connection settings </li></ul><ul><li>@@autocomit - on by default </li></ul><ul><li>can use init_connect settings to change </li></ul><ul><li>beware - superusers bypass this! </li></ul>
  23. 23. Our next GOTCHA <ul><li>collations </li></ul><ul><li>default is latin1_swedish_ci </li></ul><ul><li>'a'='A' </li></ul><ul><li>we use utf8, utf8_bin </li></ul><ul><li>'a'<>'A' </li></ul>
  24. 24. GOTCHA 3 <ul><li>autocommit=1 by default </li></ul><ul><li>wanted autocommit turned off for most code, but on for one user </li></ul>
  25. 25. GOTCHA 3 <ul><li>autocommit=1 by default </li></ul><ul><li>wanted autocommit turned off for most code, but on for one user </li></ul><ul><li>3a: init_connect and auto_commit, and that superusers bypass init_connect (which can be good) </li></ul>
  26. 26. GOTCHA 3 <ul><li>autocommit=1 by default </li></ul><ul><li>wanted autocommit turned off for most code, but on for one user </li></ul><ul><li>3a: init_connect and auto_commit, and that superusers bypass it </li></ul><ul><li>3b: security information for users is spread between information_schema and mysql databases. ‘super’ is in mysql.user, not in information_schema tables. (In case you get bitten by 3a.) </li></ul>
  27. 27. Our next GOTCHA <ul><li>SQL_MODEs - </li></ul><ul><li>Inserting inserting bad data by default, rather than giving errors </li></ul><ul><li>How 0’s can be used for null dates </li></ul>
  28. 28. GOTCHA <ul><li>error messages that are not informative or are misleading </li></ul><ul><li>eg, errors involving foreign keys, indexes, and altering tables – you’d never guess the problem from the errors: </li></ul><ul><li>MySQL Error Number 1005 Can’t create table ‘.mydb#sql-328_45.frm’ (errno: 150) </li></ul>
  29. 29. GOTCHA <ul><li>Locks are different! InnoDB locks... deal with it: </li></ul><ul><li>Writers blocking readers, readers blocking writers </li></ul><ul><li>(row-level, not like Oracle block-level) </li></ul><ul><li>Issues with foreign keys </li></ul><ul><li>isolation levels </li></ul>
  30. 30. GOTCHA <ul><li>using &quot;force index&quot; in a select doesn't really &quot;force&quot; the use of the index </li></ul><ul><li>InnoDB optimizes using a set number of &quot;random dives&quot; into a table to estimate statistics, and can still decide not to use a “forced” index </li></ul><ul><li>(not like histograms or choosing how many rows to sample for statistics in Oracle) </li></ul>
  31. 31. Care for your database <ul><li>GOTCHA: optimizing for an InnoDB table prevents updates </li></ul><ul><li>&quot;large&quot; table can take a long time </li></ul><ul><li>one multi-Gig table took hours to optimize, but then query times were cut in half </li></ul>
  32. 32. Performance… <ul><li>performance can suffer over time for inserts and updates in large tables </li></ul><ul><li>use optimize if possible (in spite of the GOTCHA) </li></ul><ul><li>&quot;insert on duplicate key update&quot; (like Oracle's &quot;merge&quot;) </li></ul>
  33. 33. So why do I love MySQL? <ul><li>you can read the code, so people know how it works (including support staff) </li></ul><ul><li>(I can understand it - it's not a black box) </li></ul><ul><li>enjoy the community (including Marten Mickos vs Larry Ellison) </li></ul><ul><li>love the support </li></ul><ul><li>it's a database - not middleware, Application server, etc. I like databases; that’s why I became a DBA. </li></ul>
  34. 34. And where do you go for help? <ul><li>Buy support! It’s worth it – cheap and very useful. </li></ul><ul><li>Read the docs, the blogs, watch planetmysql.com. </li></ul><ul><li>Do a lot of googling </li></ul><ul><li>Books I recommend: Pro MySQL by Jay Pipes (Apress) is like an “Ask Tom” type book. Sasha Pachev’s Understanding MySQL internals (O’Reilly) is a nice introduction to reading the code (if you want to) </li></ul><ul><li>(With Oracle, you have to work to read the tomes – the docs and the few good books. With MySQL, you have to work to find what you’re going to read.) </li></ul>
  35. 35. Q&A <ul><li>Ben Krug </li></ul><ul><li>DBA, Adapt Technologies </li></ul><ul><li>[email_address] </li></ul><ul><li>OSCON July 2007 </li></ul>

×