Daniel.hu [email_address]
<ul><li>HASH vs B+ Tree </li></ul><ul><li>Cluster Index vs No Cluster Index </li></ul><ul><li>INNODB vs MYISAM </li></ul>
<ul><li>Insert performance  </li></ul><ul><ul><li>Batch INSERT and REPLACE  </li></ul></ul><ul><ul><li>Use LOAD DATA inste...
<ul><li>Do you always need index on WHERE column </li></ul><ul><li>Does the order of columns in an index matter </li></ul>...
<ul><li>IN vs OR </li></ul><ul><li>large IN clauses are problematic </li></ul>
<ul><li>Explain </li></ul>
<ul><li>Make sure you strike a good balance for indexing </li></ul><ul><ul><li>Too many adversely affects data input </li>...
<ul><li>Consider the impact of duplicate rows </li></ul><ul><ul><li>Avoid SELECT DISTINCT if it doesn’t cause a problem </...
<ul><li>Operators in the WHERE clause make a big difference </li></ul><ul><ul><li>Avoid <> and LIKE </li></ul></ul><ul><ul...
<ul><li>Don’t use ORDER BY unless you really need it </li></ul><ul><li>Don’t use Count(…) where to protect data integerati...
<ul><li>http://dev.mysql.com/doc/refman/5.1/zh/optimization.html#insert-speed </li></ul><ul><li>http://www.xaprb.com/blog/...
<ul><li>Thank you! </li></ul>
Upcoming SlideShare
Loading in...5
×

Something About Mysql Database Index

1,475

Published on

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

No Downloads
Views
Total Views
1,475
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
86
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Something About Mysql Database Index

  1. 1. Daniel.hu [email_address]
  2. 2. <ul><li>HASH vs B+ Tree </li></ul><ul><li>Cluster Index vs No Cluster Index </li></ul><ul><li>INNODB vs MYISAM </li></ul>
  3. 3. <ul><li>Insert performance </li></ul><ul><ul><li>Batch INSERT and REPLACE </li></ul></ul><ul><ul><li>Use LOAD DATA instead of INSERT </li></ul></ul><ul><ul><li>Other tricks </li></ul></ul><ul><ul><ul><ul><li>Forbidden Foreign key </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Forbidden Index </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Rebuild Index </li></ul></ul></ul></ul>
  4. 4. <ul><li>Do you always need index on WHERE column </li></ul><ul><li>Does the order of columns in an index matter </li></ul><ul><li>IN vs OR </li></ul>
  5. 5. <ul><li>IN vs OR </li></ul><ul><li>large IN clauses are problematic </li></ul>
  6. 6. <ul><li>Explain </li></ul>
  7. 7. <ul><li>Make sure you strike a good balance for indexing </li></ul><ul><ul><li>Too many adversely affects data input </li></ul></ul><ul><ul><li>Too few adversely affects reads </li></ul></ul><ul><li>Order of columns in an index matters! </li></ul><ul><li>Covering indexes are the fastest query possible </li></ul>
  8. 8. <ul><li>Consider the impact of duplicate rows </li></ul><ul><ul><li>Avoid SELECT DISTINCT if it doesn’t cause a problem </li></ul></ul><ul><ul><li>Use UNION ALL instead of UNION if duplicate rows are acceptable </li></ul></ul><ul><li>Use foreign key as index or create independent index </li></ul><ul><li>Despite what you see in examples, avoid SELECT * </li></ul>
  9. 9. <ul><li>Operators in the WHERE clause make a big difference </li></ul><ul><ul><li>Avoid <> and LIKE </li></ul></ul><ul><ul><li>Use EXISTS, NOT EXISTS, and LEFT JOINS instead of NOT IN </li></ul></ul><ul><li>If you must use LIKE, make the first character a literal </li></ul>
  10. 10. <ul><li>Don’t use ORDER BY unless you really need it </li></ul><ul><li>Don’t use Count(…) where to protect data integeration </li></ul><ul><li>Don't use ORDER BY RAND() when data is huge </li></ul>
  11. 11. <ul><li>http://dev.mysql.com/doc/refman/5.1/zh/optimization.html#insert-speed </li></ul><ul><li>http://www.xaprb.com/blog/2006/07/04/how-to-exploit-mysql-index-optimizations/ </li></ul><ul><li>http://www.informit.com/articles/article.aspx?p=377652 </li></ul>
  12. 12. <ul><li>Thank you! </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×