Your SlideShare is downloading. ×
Something About Mysql Database Index
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Something About Mysql Database Index

1,444

Published on

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

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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

×