MySQL Tuning with HQ

May 7th, 2008 Scott Feldstein

This past Monday, May 5th, I had the opportunity to speak at Community One on Scaling MySQL. The presentation was based on several months of work to integrate and tune MySQL in to our fastest supported database. MySQL is the fourth database I have developed on, and while working with it I have found a bunch of nice features that are simple to use which made HQ run extremely fast. Unfortunately MySQL has some big issues with their query optimizer that made the work a bit more tedious than it needed to be.

Here are my top 3 keys to tuning MySQL ->

1) Query Tuning
Always run “explain” on your queries. Make sure they use indexes where applicable and do not table scan where you can help it.
Try to avoid using tmp tables where you can in queries. If you cannot avoid them make sure the tmp table size is as small as possible.

2) Use of Indexes
Make sure you use your clustered index / primary key wisely. For a table which is written a lot don’t use too many indexes due to overhead of CRUD operations, and on the flip side for a static table make sure it has plenty of index access points and use covering indexes where applicable.

3) Know the MySQL server options and know how to monitor them to make sure they are not out of control.

innodb_buffer_pool_size
innodb_flush_log_at_trx_commit
tmp_table_size, max_heap_table_size, and max_tmp_tables
innodb_flush_method

For slow query management, make sure you monitor the tmp table status from “show global status”
Created_tmp_files, Created_tmp_tables and especially Created_tmp_disk_tables

HQ offers a very easy and effective way to facilitate this monitoring. If these status vars grow too fast make sure to turn on your slow query log and debug the slow queries. There is usually always something that can be done.

Also, feel free to check out http://support.hyperic.com/confluence/display/DOC/MySQL+DB+Preparation for our recommended options. It is not a one size fits all, but a good place to start in order to tune the MySQL server options.

HQ running on MySQL exemplifies the potential that the database has to scale any application. It still has a ways to go in terms of features to compete in all spaces, but every major release it keeps getting better.

Here is a link to my presentation from Community One:

http://download.hyperic.com/documentation/commone-mysql.ppt

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • YahooMyWeb
  • Digg
  • e-mail
  • Facebook
  • Google
  • Reddit
  • Slashdot
  • SphereIt
  • StumbleUpon
  • Technorati
  • TwitThis

Entry Filed under: HQ

2 Comments Add your own

  • 1. server side&hellip  |  May 10th, 2008 at 6:53 am

    [...] and tune MySQL in to our fastest supported database.? MySQL is the fourth database I have dehttp://www.hyperic.com/blog/hyperic/2008/05/07/mysql-tuning-with-hq/SR Labs Unveils Low Latency OMS with Market Data Wall Street and TechnologyTo minimize latency, [...]

  • 2. adollar  |  May 21st, 2008 at 4:02 am

    Scott,

    We met at JavaOne and I met to ask you a question about text fields in tables. One of our team members attended the MYSQL conference two weeks before JavaOne. While gaining knowledge of ‘best practices’, they were of the understanding it wasn’t a ‘best practice’ to have multiple ‘text’ fields within a table where there are multiple data types. We have designed several tables containing the ‘text’ data type and not the ‘mediumtext’ or ‘longtext’. The attendee was concerned because of what they heard. The most ‘text’ fields we would have are 10 to 12 with a total of about 80 to 90 fields in any one of our tables. The attendee took from the lecture there would be a negative impact in combining the text fields with others fields and the multiple text fields should be placed in another table. Our individual tables would not contain more than a 100,000 records. Considering our table sizes along with the number of fields would there be any negative impact when there are multiple text fields within a table? If not, is the concern primarily dealing with much larger tables containing hundreds of thousands of records? Or is the concern with the ‘mediumtext’ and ‘longtext’ data types? Or is it possible there was a misunderstanding of ‘text’ fields and separate tables?

Leave a Comment

Required

Required, hidden



Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

May 2008
S M T W T F S
« Apr   Jun »
 123
45678910
11121314151617
18192021222324
25262728293031

Most Recent Posts