0
<ul>Making MySQL fast Richard Cunningham (@rythie) </ul><ul>  </ul>
FriendBinder <ul>  </ul>
<ul>How to measure </ul><ul><ul><li>MySQL slow query log
'Explain Extended' feature of MySQL
Apache custom logs, page load time (%D)
mysql> show processlist;
iostat -x 10 / munin / RDDtool etc.
On FriendBinder we have (in dev. mode): </li></ul></ul><ul><ul><ul><li>a page timer
Explain extended and times for all queries on page
Upcoming SlideShare
Loading in...5
×

Making MySQL Fast

644

Published on

A talk I gave at Multipack Show & Tell in February 2011

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total Views
644
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Making MySQL Fast"

  1. 1. <ul>Making MySQL fast Richard Cunningham (@rythie) </ul><ul>  </ul>
  2. 2. FriendBinder <ul>  </ul>
  3. 3. <ul>How to measure </ul><ul><ul><li>MySQL slow query log
  4. 4. 'Explain Extended' feature of MySQL
  5. 5. Apache custom logs, page load time (%D)
  6. 6. mysql> show processlist;
  7. 7. iostat -x 10 / munin / RDDtool etc.
  8. 8. On FriendBinder we have (in dev. mode): </li></ul></ul><ul><ul><ul><li>a page timer
  9. 9. Explain extended and times for all queries on page
  10. 10. Page load times recorded for all users </li></ul></ul></ul>
  11. 11. <ul>Hard Disks </ul><ul>Sequential performance performance of 'spinning' disk is 120Mb/sec , 1GBit network can only do 125Mb/sec, sounds good, but... What about 4KB random reads? </ul><ul><ul><li>Fast Hard disk 0.7MB/sec
  12. 12. consumer Intel SSD: 64.3MB/sec
  13. 13. RAM ~4-16,000MB/sec </li></ul></ul><ul>source: Anandtech: http://j.mp/g4lD6w </ul>
  14. 14. <ul>Indexes </ul><ul><ul><li>MySQL only uses one index per table for each query
  15. 15. A index can cover several columns but can't miss one
  16. 16. Examples...
  17. 17. WHERE user=1 AND pub_date=NOW() AND id=34
  18. 18. WHERE user=1 AND id=34
  19. 19. WHERE user=1 AND pub_date < NOW() AND id=34 </li></ul></ul>User pub_date id User pub_date id User pub_date id
  20. 20. <ul>Covering Indexes </ul><ul>A covering index is one all of the query can be resolved from the index including the WHERE, JOIN and SELECT parts. <li>Covering...
  21. 21. SELECT date_pub FROM table1
  22. 22. WHERE User=2
  23. 23. Not covering...
  24. 24. SELECT name FROM table1
  25. 25. WHERE user=2 </li></ul>User pub_date id User pub_date id
  26. 26. <ul>Clustered Indexes </ul><ul>In the MyISAM table type new records are simply added to the end of file. Problem is that queries often are jumping all around the file. <li>In InnoDB the records are stored in order of the primary key </li></ul>
  27. 27. <ul>What not to index </ul><ul><ul><li>Binary columns - these are not selective enough, MySQL will never use it
  28. 28. Subset indexes of other indexes
  29. 29. Anything you don't have a query for – design indexes for queries </li></ul></ul>User pub_date User pub_date id
  30. 30. <ul>Further Information </ul><ul><ul><li>This book has more... </li></ul></ul><ul><li>Contacting me: </li><ul><li>@rythie
  31. 31. www.rythie.com
  32. 32. [email_address] </li></ul></ul>
  1. Gostou de algum slide específico?

    Recortar slides é uma maneira fácil de colecionar informações para acessar mais tarde.

×