Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm running a MySQL 5.5 server on my workstation for scientific data analysis and wonder how to configure MySQL in order to get the most out of it performance-wise. The types of query that I typically run involve joins of 10-20 tables and can run for quite long, one to several minutes being no exception at all. Only very few users access the database at the same time (5 being the maximum). I moved the server from a Lenovo Thinkpad T61 with a 2.2 GHz Dual Core and 4 GB of RAM to the following brand-new machine with hand-selected components:

  • Intel i7 3770, 4x 3.4 GHz (running @ 4x3.7 GHz)
  • Z77 chipset
  • 16 GB of DDR3 1600 RAM
  • Windows 7 Prof 64-bit
  • Windows and MySQL server run on a Intel 520 series SSD drive.

First tests (running the same query on both machines) showed a definitive improvement in speed for the new one, but the queries still take a lot of time and I had expected more of a boost. The queries in question are fairly well optimized, i.e. all tables have proper key that are also being used as of "explain extended".

Now to my current MySQL settings: First I should mention that I moved from MyISAM to Innodb long time ago.

Some of my my.ini tweaks (i.e. departures from default settings):

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
#tmp_table_size=35M
tmp_table_size=4000M
max_heap_table_size=4000M

# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
# row data. The bigger you set this the less disk I/O is needed to
# access data in tables. On a dedicated database server you may set this
# parameter up to 80% of the machine physical memory size. Do not set it
# too large, though, because competition of the physical memory may
# cause paging in the operating system.  Note that on 32bit systems you
# might be limited to 2-3.5G of user level memory per process, so do not
# set it too high.
#innodb_buffer_pool_size=96M
innodb_buffer_pool_size=800M

general-log
expire_logs_days = 60
general_log_file = "F:/my_query_mysql.log"
log-output = TABLE
optimizer_search_depth = 0 #meant to cure the "statistics state" bug in some queries

I'd like to know whether somebody would suggest changes to the above numbers or even further settings that I do not know of.

I'd appreciate any helpful remark.

Steve

EDIT: I have two queries involving joins across 10-20 tables and ran them on my Lenovo notebook and the new PC. Query #1 took 3m36s on the new machine vs 9m11s on the laptop; Query #2 took 22.5s on the workstation vs 48.5s on the laptop. So the execution speed was improved by roughly the factor 2-2.5. On the workstation, not even 50% of the RAM was used. The average CPU load across the four cores (as reported by Windows Task Manager) was only about 13%. The load on a per-core basis (as reported by Core Temp) was about 25-40% for ONE core, while it was <=10% for the others, indicating that MySQL does not make use of multiple cores for a single query.

share|improve this question

migrated from stackoverflow.com Jul 22 '12 at 6:12

This question came from our site for professional and enthusiast programmers.

    
Please show your server load, so check memory, io, cpu loads etc. –  Luc Franken Jul 21 '12 at 10:41
    
I'll run some tests and report back what Windows Task Manager has to say (or would you advise a better tool?) –  Steve06 Jul 21 '12 at 10:44
    
That should be enough for a first indication to see where your issue is. –  Luc Franken Jul 21 '12 at 10:51
    
just added some stats. –  Steve06 Jul 21 '12 at 22:10
2  
In addition you can also try out the Percona wizard to get "recommended" settings for your database server at tools.percona.com/wizard –  ssmusoke Jul 22 '12 at 8:23
show 5 more comments

3 Answers 3

Since you are running MySQL 5.5, you may want to consider configuring InnoDB to access multiple cores

Here are the settings you should be using

innodb_thread_concurrency sets the upper bound on number of concurrent threads that InnoDB can hold open. Best round number to set for this is (2 X Number of CPUs) + Number of Disks. UPDATE : As I learned firsthand from the Percona NYC Conference, you should set this to 0 in order to alert InnoDB Storage Engine to find the best number of threads for the environment it is running in.

innodb_concurrency_tickets sets the number of threads that can bypass concurrency checking with impunity. After that limit is reached, thread concurrency checking becomes the norm again.

innodb_commit_concurrency sets the number of concurrent transactions that can be committed. Since the default is 0, not setting this allows any number of transactions to commit simultaneously.

innodb_thread_sleep_delay sets the number of milliseconds an InnoDB thread can be dormant before reentering the InnoDB queue. Default is 10000 (10 sec).

innodb_read_io_threads and innodb_write_io_threads (both since MySQL 5.1.38) allocate the specified number of threads for reads and writes. Default is 4 and maximum is 64.

innodb_replication_delay imposes thread delay on a slave is innodb_thread_concurrency is reached.

Here are my past posts on MySQL 5.5 and activating multiple cores for InnoDB

share|improve this answer
add comment

Percona- Leading MySQL consultant offers a MySQL configuration wizard. It lets you to configure my.cnf/my.ini depending on your system configuration.

Also Percona people have released a book called "High Performance MySQL". The third edition was recently released, and covers tuning in great detail.

share|improve this answer
    
are these values what they suggest for good performance, or does it just spit out what I enter? –  opensourcechris Apr 11 '13 at 16:55
add comment

Memory usage: see http://mysql.rjweb.org/doc.php/memory (Most tunables won't make enough difference to matter.)

max_heap_table_size=4000M is Dangerously high! If 4 users need such, you are out of RAM and swapping. Swapping hurts performance much more than virtually anything.

Queries taking more than a few seconds: They should be studied for improvement; please provide SHOW CREATE TABLE; SHOW TABLE STATUS; EXPLAIN SELECT

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.