Newsletter Subscription | Glossary | Contact Us
Home > All Categories > MySQL > Tuning > 15 tips on optimising MySQL databases and MySQL queries
Question Title 15 tips on optimising MySQL databases and MySQL queries
Authored by: Ram
Viewed: 799 times so far

I have been reading articles on how to optimise MySQL databases and queries and here are a few tips I have learnt and would like to share with you:

  1. Proper use of indexes improve performance
  2. Do not perform calculations on an index (eg: if you have an index for a column called salary, do not perform calculation such as salary * 2 10000)
  3. Do not perform calculations on an index (eg: if you have an index for a column called salary, do not perform calculation such as salary * 2 >
  4. “LOAD DATA INFILE” is the fastest way to insert data into MySQL database (20 times faster than normal inserts)
  5. Use INSERT LOW PRIORITY or INSERT DELAYED if you want to delay inserts from happening until the
    table is free
  6. Use TRUNCATE
    TABLE rather than DELETE FROM if you are deleting an entire table (DELETE FROM delete row by row, whereas TRUNCATE TABLE deletes all at once)
  7. Always use EXPLAIN to examine if your select query is efficient
  8. Use OPTIMIZE
    TABLE to reclaim unused space (Note: Table will be locked during optimisation, so only do it during low traffic time)
  9. Better to have 10 quick queries than 1 slow one
  10. Use caching to reduce database load
  11. Normalize tables to ensure
    data consistency
  12. Use persistent connections
  13. Don’t query columns you don’t need, avoid using SELECT * FROM
  14. MySQL can search on prefix of indexes (ie: If you have index INDEX (a,b), you don’t need an index on (a))
  15. Don’t use HAVING when you can use WHERE
  16. Use numeric values (rather than alphabetical values) when performing a join
Click Here to View all the questions in Tuning category.
File Attachments File Attachments
There are no attachment file(s) related to this question.
User Comments User Comments
There are no user comments for this question. Be the first to post a comment. Click Here
Post Comment Add a Comment
Email Address:
Comment/Message
Verify Code

Post Comment How helpful was this article to you?
Related Questions Related Article
  1. Real World Web: Performance & Scalability, MySQL Edition
  2. A Few Common Performance Mistakes
  3. MySQL Conference Keynote 2008 - Scalability Panel
  4. Multiple column index vs multiple indexes
Article Information Additional Information
Article Number: 40
Created: 2008-01-13 12:51 PM
Rating No Rating
 
Article Options Article Options
Print Question Print this Question/Article
Email Question Email this Question/Article to Friend
Export to MS Word Export to MS Word
Bookmark Article
del.icio.us Bookmark del.icio.us Bookmark
Digg It Digg It
Furl It Furl It
Subscribe to Article Subscribe to Article
 
Language Translation Language Translation
 
Search Knowledge Base Search Knowledge Base