Wednesday, November 23, 2011

Tips to optimize MySQL for better performance

I ave been working on my project www.edugoog.com and try to optimise queries. To do so I came through many articles. I gathered basic points from the same. Please find my finding below and feel free to add more in comments if missed.
  1. Don’t query columns you don’t need, avoid using SELECT * FROM
  2. Use caching to reduce database load
  3. Normalize tables to ensure data consistency
  4. Use persistent connections
  5. Proper use of indexes improve performance
  6. 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)
  7. “LOAD DATA INFILE” is the fastest way to insert data into MySQL database (20 times faster than normal inserts)
  8. Use INSERT LOW PRIORITY or INSERT DELAYED if you want to delay inserts from happening until the table is free
  9. 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)
  10. Always use EXPLAIN to examine if your select query is inefficient
  11. Use OPTIMIZE TABLE to reclaim unused space (Note: Table will be locked during optimisation, so only do it during low traffic time)
  12. Better to have 10 quick queries than 1 slow one
  13. MySQL can search on prefix of indexes (ie: If you have index INDEX (a,b), you don’t need an index on (a))
  14. Don’t use HAVING when you can use WHERE
  15. Use numeric values (rather than alphabetical values) when performing a join
Thanks

11 comments:

  1. I like the valuable information you provide in your articles. I’ll bookmark your weblog and check again here regularly. I’m quite certain I’ll learn plenty of new stuff right here! Good luck for the next!
    snow removal

    ReplyDelete
  2. I hate blogs with ads and publicity thing, a good blog is to inspire people and happy, make life more rich and wonderful, let more open perspective.

    University of Phoenix Online

    ReplyDelete
  3. This post shows the information which is close to standard. Hope next You will again post a nice Article/Information.

    dallas veneers

    ReplyDelete
  4. I wholeheartedly agree with your review.



    aion accounts

    ReplyDelete
  5. I agree with your conclusions and will eagerly look forward to your incoming updates. Just saying thanks will not just be adequate, for the wonderful clarity in your writing.It is imperative that we read blog post very carefully
    moving company in sacramento

    ReplyDelete
  6. I really appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You’ve made my day! Thanks again! “One never goes so far as when one doesn’t know where one is going.
    University of Phoenix Online

    ReplyDelete
  7. I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.

    copper signs

    ReplyDelete
  8. I really appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You’ve made my day! Thanks again! “One never goes so far as when one doesn’t know where one is going.

    University of Phoenix Online

    ReplyDelete
  9. Your article is simply fabulous. It’s got a lot of interesting information that is well-written, engaging and intelligent. Your ideas are very smart and fresh. Thank you for creating such unique content for your readers.
    online classes

    ReplyDelete
  10. This is definitely a blog that people need to get behind. The problem is, no one wants to do a great deal of reading and not have something else to stimulate the mind.


    WOW gold

    ReplyDelete
  11. For your work you need a themes to make it a file for you to visit this site wordpress protfolio themes

    ReplyDelete