What to tune in MySQL Server after installation

My favorite question during Interview for people to work as MySQL DBAs or be involved with MySQL Performance in some way is to ask them what should be tuned in MySQL Server straight after installation, assuming it was installed with default settings.

I’m surprised how many people fail to provide any reasonable answer to this question, and how many servers are where in wild which are running with default settings.

Even though you can tune quite a lot of variables in MySQL Servers only few of them are really important for most common workload. After you get these settings right for your initial MySQL performance tuning, other changes will most commonly offer only incremental performance improvements.

key_buffer_size – Very important if you use MyISAM tables. Set up to 30-40% of available memory if you use MyISAM tables exclusively. Right size depends on amount of indexes, data size and workload – remember MyISAM uses OS cache to cache the data so you need to leave memory for it as well, and data can be much larger than indexes in many cases. Check however if all of key_buffer is used over time – it is not rare to see key_buffer being set to 4G while combined size of .MYI files is just 1GB. This would be just a waste. If you use few MyISAM tables you’ll want to keep it lower but still at least 16-32Mb so it is large enough to accommodate indexes for temporary tables which are created on disk.

innodb_buffer_pool_size This is very important variable to tune if you’re using Innodb tables. Innodb tables are much more sensitive to buffer size compared to MyISAM. MyISAM may work kind of OK with default key_buffer_size even with large data set but it will crawl with default innodb_buffer_pool_size. Also Innodb buffer pool caches both data and index pages so you do not need to leave space for OS cache so values up to 70-80% of memory often make sense for Innodb only installations. Same rules as for key_buffer apply – if you have small data set and it is not going to grow dramatically do not oversize innodb_buffer_pool_size you might find better use for memory available.

innodb_additional_mem_pool_size This one does not really affect performance too much, at least on OS with decent memory allocators. Still you might want to have it 20MB (sometimes larger) so you can see how much memory Innodb allocates for misc needs.

innodb_log_file_size Very important for write intensive workloads especially for large data sets. Larger sizes offer better performance but increase recovery times so be careful. I normally use values 64M-512M depending on server size.

innodb_log_buffer_size Default for this one is kind of OK for many workloads with medium write load and shorter transactions. If you have update activity spikes however or work with blobs a lot you might want to increase it. Do not set it too high however as it would be waste of memory – it is flushed every 1 sec anyway so you do not need space for more than 1 sec worth of updates. 8MB-16MB are typically enough. Smaller installations should use smaller values.

innodb_flush_log_at_trx_commit Crying about Innodb being 100 times slower than MyISAM ? You probably forgot to adjust this value. Default value of 1 will mean each update transaction commit (or each statement outside of transaction) will need to flush log to the disk which is rather expensive, especially if you do not have Battery backed up cache. Many applications, especially those moved from MyISAM tables are OK with value 2 which means do not flush log to the disk but only flush it to OS cache. The log is still flushed to the disk each second so you normally would not loose more than 1-2 sec worth of updates. Value 0 is a bit faster but is a bit less secure as you can lose transactions even in case MySQL Server crashes. Value 2 only cause data loss with full OS crash.

table_cache – Opening tables can be expensive. For example MyISAM tables mark MYI header to mark table as currently in use. You do not want this to happen so frequently and it is typically best to size your cache so it is large enough to keep most of your tables open. It uses some OS resources and some memory but for modern hardware it is typically not the problem. 1024 is good value for applications with couple hundreds tables (remember each connection needs its own entry) if you have many connections or many tables increase it larger. I’ve seen values over 100.000 used.

thread_cache Thread creation/destructions can be expensive, which happen at each connect/disconnect. I normally set this value to at least 16. If application has large jumps in amount of concurrent connections and I see fast growth of
Threads_Created variable I boost it higher. The goal is not to have threads created in normal operation.

query_cache_size If your application is read intensive and you do not have application level caches this can be great help to optimize your MySQL database. Do not set it too large as it may slow things down as its maintenance may get expensive. Values from 32M to 512M normally make sense. Check it however after a while and see if it is well used. For certain workloads cache hit ratio is lower than would justify having it enabled.

Note: as you can see all of these are global variables. These variables depend on hardware and mix of storage engines, while per session variables are typically workload specific. If you have simple queries there is no reason to increase sort_buffer_size even if you have 64GB of memory to waste. Furthermore doing so may decrease performance.
I normally leave per session variable tuning to second step after I can analyze workload.

P.S Note MySQL distribution contains bunch of sample my.cnf files which may be great templates to use. Typically they would already be much better than defaults if you chose correct one.

More free resources that you might find useful


Blog Posts

White Papers & eBooks

Share this post

Comments (107)

  • Rasmus Møller


    our old MySQL 4.1 server has started to fail during a large SELECT INTO OUTFILE 4.5 mio records totalling 1.5GB with an “ORDER BY” statement at the end.

    If we test run without “ORDER BY” there is no error.
    If we select fewer records there is no error.

    We are p.t. not at liberty to upgrade Windows nor MySQL version nor are we allowed to change the SQL statement.

    Are there any MY.INI config parameters which should be tweaked?

    September 29, 2006 at 12:00 am
  • Wagner Bianchi

    Normally, I have been adding skip-name-resolve on both sides, on both MySQL Servers involved on a remote connection.

    ERRATA on my last interaction:

    SHOW VARIABLES LIKE ‘key%’ will show you all variables involved in maintain key_buffer_size internal system and SHOW STATUS LIKE ‘key%’ will show you MySQL key_buffer_size status variables what is the snapshot of key_buffer behavior.

    September 29, 2006 at 12:00 am
  • benhur

    Daer sir,

    Kill 20509 unauthenticated user 89.x.x.x:2501 None Connect Reading from net —

    I have already added the skip-name-resolve, skip-host-cache, and skip-locking option to my.cnf. As a added measure I have already added the IP Address to the /etc/hosts and the privileges for the user and IP address has also been granted in the database already.

    still problem is there can any abody please help

    Please help.


    September 29, 2006 at 12:00 am
  • sjc

    Thanks Peter, nice summary of these tuning settings.

    A question: I have a database using only MyISAM with about 6GB of data, 4GB of index files (largest index is nearly 1.7GB) running on a box with 4GB of memory. I’ve currently got the key_buffer_size set to 1.5GB, and I’m finding performance on the large tables can vary hugely, presumably dependent on whether the index for those tables is currently loaded or not. I’m working on a medium-term solution to get rid of those huge indexes entirely, but in the meantime can you suggest a suitable size for the key buffer? My current thinking is to *lower* the size of it in order to give the OS a better chance of caching all the files.


    – s

    September 29, 2006 at 6:56 am
  • peter

    Surely performance will be very different if data is in memory or not. If you have some particular indexes which you need to have in memory you can use LOAD INDEX INTO CACHE to preload them. You can even have separate keycache for them to ensure they are not replaced by other data.

    Your 1.5GB key buffer looks reasonable but I can’t tell if it is optimal for your workload or 1GB will be better. Run some benchmarks and see yourself.

    September 29, 2006 at 7:05 am
  • Roland Bouman

    Hi Peter,

    What an excellent and valuable overview.

    I sometimes wonder if these are just the teasers and there’s still a box of well hidden secrets that you keep away for consulting gigs 😉

    Anyway, concerning innodb_flush_logs_at_trx_commit:

    “Value 0 is a bit faster but is a bit less secure as you can lose transactions even in case MySQL Server crashes. Value 2 only cause data loss with full OS crash.”

    To be clear, we could loose *committed* data in these cases, right?

    September 29, 2006 at 10:43 am
  • peter


    I keep no secrets I do not need it. Normally the problem is not what information is unavailable – with OpenSource you can argue everything is open but applying this information to particular problem and finding bits and pieces relevant for particular case, so are analytical skills. It is impossible to remember everything these days 🙂

    About innodb_flush_logs_at_trx_commit – yes you’re right if you have it set to 0 or 2 you can loose commited data on the crash. The difference is it is MySQL crash for value 0 and full OS crash for value 2, which is why it is better.

    September 29, 2006 at 10:53 am
  • James Day

    Roland, as Peter says, no need to hide, the skill comes in knowing what to apply in a specific context and what to look for first.

    James Day

    September 29, 2006 at 12:31 pm
  • Ruslan Zakirov

    Is table_cache important for InnoDB setups?

    September 29, 2006 at 1:02 pm
  • peter

    James, Thanks for translation 🙂

    Ruslan – it is less of the issue for Innodb but still .frm needs to be read etc. So I prefer to keep it simple 🙂

    September 29, 2006 at 1:28 pm
  • Roland Bouman

    Hi Peter, James

    I trust you understand my remark was meant to be tongue-in-cheek.

    I’m just very much thrilled to see how Peter is openly sharing all this valuable knowledge, and in such a practical manner. I think it’s quite obvious that hiring his consultancy for performance issues is bound to lead to results – a good thing to know when you are hiring a consultant. Some (if not most) consultants might decide to be less detailed in offering such practical tips in fear of devaluating their skills.


    Roland Bouman

    September 30, 2006 at 5:00 am
  • peter


    You’re right. I prefer to be open in sharing my knowledge/ideas when it comes to MySQL as well as other areas of expertise. I do not think I will drain me. I think the knowledge is more like the stream than like a lake, and sharing it does not decrease it. Furthermore I learn more by sharing.

    I also try to be very forthcoming in my pre-sales calls. I openly share what I think might be wrong based on information they provide during these 15 minutes. This allows customers to be confident I know what I’m doing and if this little tip was only what they needed to solve their problems I’m fine with having provided it for free.

    September 30, 2006 at 8:24 am
  • Jakiao

    You comment that setting key_buffer to 4G is not uncommon. What if you need to go over 4G? I have noticed that no matter what value you set it at, it will always restrict you to a maximum of 4G.

    October 3, 2006 at 2:10 am
  • Jakiao

    I should probably mention that I’ve noticed this limit on a Linux 2.6.18 x86_64.

    October 3, 2006 at 2:14 am
  • peter

    key_buffer has some internal implementation issues which limits its size to 4G. These are to be fixed in one of next MySQL versions but currently you should stick to this size.

    October 3, 2006 at 2:18 am
  • Mike

    Thanks again – this is excellent information! I’m curious, though, how one would go about setting some of these things on a system with lots of RAM (32G), but with the inherent per-process memory limitations of a 32-bit system. I work with a couple of servers with 8 P3 Xeon processors and 32G of RAM each. I know some buffers are allocated only once for all MySQL threads/processes, and others are per-thread or per-connection.

    October 3, 2006 at 11:06 am
  • peter


    I thought these beasts are all dead by now. But seriously if you are with 32bit and running Linux you can only allocate buffers up to some 2.5GB or so (depending on a lot of factors) – the rest will be only used as OS cache, which is less efficient. On Windows Innodb also can use AWE for caching which you can try to use.

    October 3, 2006 at 11:23 am
  • Jakiao

    Is there anyway I can compile my own MySQL binaries and change this 4GB limit? We won’t be able to use MySQL 5.x for many months, and utilizing RAM is key here. This 4GB limit seems to have no place other than to cause headaches.


    October 3, 2006 at 3:46 pm
  • peter


    MySQL does not have a limit of memory it can use on 64bit systems, it applies to all versions. There is a limit however for particular key_buffer variable which should not be over 4GB. There are some code fixes needed to make it work so it is not simply question of recompiling.

    October 4, 2006 at 6:35 am
  • James Day

    Jaiko, consider multiple key buffers to get around the 4GB limit if you are using MySQL 4.1 or later.

    October 4, 2006 at 12:58 pm
  • peter

    Thanks James. I forgot about that one.

    I do not generally like using MyISAM in cases when more than 4GB of buffer may be required. Tables with such large indexes may take a while to recover.

    October 4, 2006 at 1:36 pm
  • Jakiao

    Hey all,

    I am attempting multiple key_cache’s, it’s just a matter of determining which tables to assign to the alternate cache.

    One thing I noticed is that the primary cache, when set to 4GB, usage never goes over 2GB. Once it reaches 2GB, it drops back to 1.8GB or so. After adding a second key_cache, I’ve notice it go past that 2GB mark.

    Thanks for taking the time to answer my questions. I appreciate it.

    October 4, 2006 at 9:08 pm
  • Caleb

    Great article. Thanks for it.

    I’ve got a situation that I’ve been trying to figure out for some time now and I haven’t really gotten anywhere with it, unfortunately…

    My VPS has 256mb ram and all of mysql resources are fine with the current setting I have, or at least appear to be – except my tmp_table_size. I’ve got 110mb assigned to it and still 50% or more of the tmp tables created are disk based. (as compared to my key_buffer allocation, for instance, which only has 16mb assigned to it but keeps the fill ratio only between 40-50%).

    My current settings:

    max_connections = 300
    max_user_connections = 300
    key_buffer = 16M
    myisam_sort_buffer_size = 16M
    read_rnd_buffer_size = 1M
    join_buffer_size = 2M
    read_buffer_size = 1M
    sort_buffer_size = 2M
    table_cache = 1000
    thread_cache_size = 200
    interactive_timeout = 25
    wait_timeout = 30
    connect_timeout = 10
    max_allowed_packet = 2M
    max_connect_errors = 1000
    query_cache_limit = 1M
    query_cache_size = 12M
    query_cache_type = 1
    tmp_table_size = 110M

    Any light anyone can shed on this would be really awesome. 🙂

    October 6, 2006 at 12:44 pm
  • Shaheryar

    Great information Peter,

    I am facing a problem these days with MySQL. I have a table that has 3.3 million records (size is around 500 MB) that stores records of members. Now I need to update the records of this table by reading data from a file that contains 1 million email addresses and I need to update one field of those records whose email address is in the file. I created a script, reading 1 email address from file and trying to update the table on email field (that is not primary key but an index has been applied to it) and it takes 6-7 seconds in updating one record that means it will require days to update the whole table. I changed it to first select the primary key of the given email and then trying to update it but there was little difference in result. What settings you suggest for MySQL and what approach to update of the two I just described. Table type is MyISAM and MySQL version is 4.1.21-standard.

    October 13, 2006 at 1:45 am
  • peter


    First I should ask you to ask unrelated questions at Forums: http://forum.mysqlperformanceblog.com/s/f/2/ rather than use post comments.

    In your case I would run EXPLAIN for SELECT statement similar to update you’re using, it really feels like it is not using index for some reason.

    Generally your method is fine. Depending on the data you have in the file you might be able to load it in the table and write single query which performs an update, but it will need to do similar operation internally anyway.

    October 13, 2006 at 5:20 am
  • Josh

    I am curious what you think about mixing table types. I have 2 web applications and they are integrated with a site. Now these web apps use MyISAM tables, but I would prefer to use transaction safe tables on the site itself and convert the few web app tables into InnoDB that I insert data into from the site. Then just allow the webapps to use MyISAM on the rest of their tables.

    Is it best to just stick with one table type performance wise?

    October 15, 2006 at 12:13 am
  • peter

    Josh, Same suggestion to you – please use forums for your questions instead of using comments for unrelated posts.

    Mixing table types is OK. I do it all the time. The thing you should care in terms of performance is mainly memory competition – you will need both allocate memory for OS cache and key_buffer for MyISAM tables and innodb_buffer_pool for Innodb tables and ballancing these might be complicated for performance fine tuning.

    October 16, 2006 at 5:29 am
  • Spud

    i’ve some two forum tables with abot 700Mb each one, and they was type myisam. I was getting some lock problems and i decided to switch them to innodb, but server load growed from 3 to 20. I followed your steps but i got not any server load improvements.

    should i back to myisam? or is there any way to solve it?

    thanks 😉

    October 19, 2006 at 4:04 pm
  • peter


    Please ask your question at the forum http://forum.mysqlperformanceblog.com/s/f/2/ rather than here if you want to get an answer

    October 20, 2006 at 7:56 am
  • the_dbatrix

    This is great information thank you. I’m getting used to mySQL after many years in Oracle, and I’m curious as to what metrics can be reviewed to iteratively tune this parameters. For instance, INNODB_BUFFER_POOL_SIZE… how can I evaluate hit ratios to determine if this is undersized? Sure, I may see excessive IO in IOStat, but how do I know it’s from this, versus from disk sorts, or myISAM queries not using the query cache and key cache?

    I’ve noticed in the Administrator GUI tool you can see hit ratios for query cache and key cache in myISAM. Are there underlying sql commands I can run to get this to evaluate the efficiency of my variable settings?

    Thanks again, I’ve found reading through your blog quite illuminating.

    October 23, 2006 at 6:29 pm
  • peter

    You can run SHOW INNODB STATUS (it is also available in SHOW STATUS in MySQL 5.0+) – this will show you number of buffer pool pages reads/writes per second which is what you can use to differ Innodb IO from anything else.

    October 24, 2006 at 3:32 am
  • Arul


    You can use the “start transaction + commit” pair to speed up your work. There are different commands for MyISAM and INNODB (can’t remember). Check it out and try it.

    My experience: I once had to load a 1.7 million record table into the DB. Initially the estimated time taken was a few hours. Then I tried the above pair. The upload was completed in 15 minutes! Assuming you are uploading a .sql file, MySQL reads each line and executes it and moves down to the next. With the “Start Transaction” and “Commit” around a chunk of query, SQL will not execute until it reaches the “commit”. So I figure that cuts down drastically on overhead processing.

    October 25, 2006 at 8:34 pm
  • jgabios

    also a good thing is to log your slow queries with:
    I set it to 1 second because my mysql in in web environment and if something takes more than a second, then the users will wait a lot for the page to load and never come back.

    November 17, 2006 at 3:15 am
  • Rohan


    I’m facing problem of slave servers are getting behind master. I’ve one slave and three slave. All slave are getting behind master.
    Server details
    Dual Xeon, 4 GB ram
    All servers are on same gig network.
    All my tables are MyIsam.

    Following is out of mytop

    MySQL on localhost (5.0.22-standard-log) up 12+23:09:57 [13:00:53]
    Queries: 598.6M qps: 560 Slow: 0.0 Se/In/Up/De(%): 03/00/00/00
    qps now: 4928 Slow qps: 0.0 Threads: 37 ( 34/ 2) 01/00/00/00
    Key Efficiency: 100.0% Bps in/out: 0.0/ 0.5 Now in/out: 42.0/18.7k

    qps varies from 3000 to 8000.


    key_buffer = 4096M
    max_allowed_packet = 32M
    table_cache = 812
    sort_buffer_size = 1024M
    read_buffer_size = 512M
    myisam_sort_buffer_size = 1024M
    thread_cache = 16
    query_cache_size = 512M
    max_connections = 300
    max_user_connections = 300
    max_connect_errors = 99
    interactive_timeout = 10
    # Try number of CPU’s*2 for thread_concurrency
    thread_concurrency = 8

    Please suggest which parameter to tweak. And where to look for the problem

    Waiting for your reply.


    December 7, 2006 at 12:31 am
  • peter


    Please use forum.mysqlperformanceblog.com for such questions.
    In general I’m surprised it works at all, your sort_buffer_size and read_buffer_size are way off.

    Slaves can get behind master ether because write load is high or if you load slaves with reads too much.

    December 7, 2006 at 2:54 am
  • nustchen

    Deal Peter:
    Hi. First my english is very poor. Please forgive me for my grammar mistake.
    Your article is very useful for me. But I still want to know how can I tune “sort_buffer_size”.
    What status can I use to monitor the performance improvement when I tuned “sort_buffer_size”.

    December 25, 2006 at 10:45 pm
  • peter

    You would normally look at sort_merge_passes status variable. If this variable is increased sort_buffer was not enough to accommodate all data to perform the sort and file based sort was used. Note you do not always have to increase global sort_buffer value. In many cases setting per connection variable before running long queries would be good enough.

    December 28, 2006 at 5:49 am
  • Flasher

    Hi Peter,

    Its realy nice post.

    i want to create a table for templates and replace the type of files .tpl [for Smarty-Light]

    so which is the best type for my table ( MyISAM or InnoDB ) ?

    and Thanks..

    December 29, 2006 at 9:18 pm
  • peter


    I did not exactly get your question. Also it is best to ask unrelated questions at forum.mysqlperformanceblog.com

    December 30, 2006 at 1:52 am
  • merlin

    I have a mysql server with 300+ workstations connecting to it and my server has only 4 GB. sometimes the server has 3000+ qps. on the average it has 125 qps.

    is 4GB enough since were adding more workstations that will be inserting records to this server? I was told that a standard mysql server must have at least 16 GB ram — true?

    February 7, 2007 at 8:53 am
  • peter


    MySQL can run with very low amount of memory. 16GB is not required and it is surely not the lowest number.

    Database size and workload define how much memory you’ll need.

    February 8, 2007 at 6:20 am
  • merlin

    I have 65 tables now at 4.3 GB. One table has 6 million rows. Now we average at 300+ queries per second. Average threads at 150+

    How do I optimize my box?

    February 8, 2007 at 7:00 am
  • youtube videos

    It could be helpful to show example my.cnf files for sample configurations.

    March 4, 2007 at 1:46 pm
  • Strafverteidiger München

    James, Thanks for translation. very cool job.

    April 19, 2007 at 11:05 am
  • Ewin Barnett

    I am working building a simple table based on a very large sequential file of about 50 million titles that are in random order. I plan two indexes, one of just the title and one composed of only a date. Can anyone suggest if it would be better to use MyISAM or InnoDB?

    May 13, 2007 at 2:21 pm
  • youtube video izlesene

    James, Thanks for translation. very cool job.

    sometimes i got an error like this .. “mysql max_connection_user has a lot connection” .. what does it mean ?.. when i restart the httpd and mysql it will be resolve ..

    someone can help me about that .

    July 23, 2007 at 7:46 pm
  • Blue System

    Hi every1,
    Database size and workload define how much memory you’ll need.
    any formula from this?? I really have problem on this now.
    pls help !!! extremely urgent.


    September 6, 2007 at 2:22 am
  • meeero


    thank you for all that information, i’ve used the defauls all the time on a mysql-server with heavy load… now i’ll see how the changes affect everyday-operation

    October 4, 2007 at 6:41 pm
  • Jitendra Thakor

    Hello every one
    Que:I create webapplication of company and i use mysql server
    but after some trasaction application sql server speed much down
    so i am not get reply sooon
    i send request through Ajax

    October 19, 2007 at 11:40 pm
  • Anil Kumar MS

    Hi friends,iam using MySQL5.0.

    I have a database with 2mb size.There are more than 30 tables.

    In a query, iam using joins to retrieve records from db.which joins 10 tables.Iam using windows 2003 server with 1GB RAM.Please specify the optimum settings for this hardware.Data will be bulk.

    November 1, 2007 at 12:32 am
  • ahmed

    If I have an insert/update and a delete statement in a mysql stored procedure,does it mean that the second statement(delete) is executed only after the inserts/updates are completed ? Or do they all run concurrently.If yes,how to make them run one after another?

    January 8, 2008 at 10:41 pm
  • Michael

    Anil, major optimum setting: move off of windows anything, to anything else..anything is an improvement. All the rest of us already know this. Why don’t you?

    January 14, 2008 at 7:49 am
  • ztej

    Hi Peter, this article actual a 2008 year, thanks

    January 22, 2008 at 12:10 pm
  • ramkiran

    how to determine the installed instance name?

    can any bosy help me in the form of a query

    April 2, 2008 at 4:40 am
  • Dane Jensen

    Great guide! One question, is there any sort of performance gain/penalty from using innodb_file_per_table?

    And one small correction, it should be ‘innodb_flush_log_at_trx_commit’ (singular log), rather than ‘innodb_flush_logs_at_trx_commit’ it seems.

    June 20, 2008 at 4:00 pm
  • Roel

    innodb_flush_logs_at_trx_commit should be innodb_flush_log_at_trx_commit (no s)

    July 7, 2008 at 6:09 pm
  • peter

    Thanks. Fixed 🙂

    July 7, 2008 at 7:41 pm
  • Sam Nicolosi

    I am a registered user on a couple of “blogs” (websites) that allow articles to be discussed (by registered users). And the users are given a opportunity to “edit” his/her own post during a 30 minute period following submission of same.
    One of the sites where I am encountering a problem is: commondreams.org

    Each time I try to EDIT one of my posts, I am allowed (once) to perform the edit, but I then immediately receive this message:

    “WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1]

    SELECT comment_content, comment_author_IP, comment_date_gmt FROM wp_comments
    WHERE comment_ID =

    You aren’t allowed to edit this comment, either because you didn’t write it
    or you passed the 30 minute time limit.”

    I am using a PC running Windows XP, and using either Firefox or Internet Explorer
    (the problem occurs with either browser).

    What is “my SQL syntax”?
    Where does it “reside”?
    How can I “fix it”?
    Is there some nifty “patch” that will fix it for me?
    I am not a “tech-type”, so please try not to answer me in “Computereese”


    July 27, 2008 at 2:17 pm
  • Jitendra

    Hi, Peter,

    I am new to mysql setting level.

    Right now I am working in a PHP-Mysql base project in which we have one job table and one url master table.
    Job table contains 15000000 records and url table contains 25000 record. Every day we are crawling all the urls and if there is any new job on those url then we will insert that record in our job table. Show each and every day there are near 100000 new job record inserted into job table.

    Right now out both table type is ‘innodb’.

    But problem is right now our query takes two much time for duplicate checking and other type processes.

    Can you please tell me what are the settings required in mysql for incressing performance of my project.

    Also can you please tell me that the type of table ‘innodb’ is OK ro not..

    Below are the my server ‘SHOW STATUS’ output;

    Key_read_requests 9490927
    Key_reads 72073
    Key_write_requests 678314
    Key_writes 430602
    Open_tables 561
    Open_files 278

    Thanks !

    September 5, 2008 at 10:36 pm
  • http://blog.colnect.com/

    Comment by “Sam Nicolosi” (no.81) is simply spam. WTF would some1 write such a long message in a place that’s completely irrelevant if not for the sole purpose of including a url?

    Anyway, very nice and helpful post. I’ve posted my question in your forum.
    This blog comes up on almost any mySQL config variable I search on Google 🙂

    October 18, 2008 at 4:55 pm
  • Jeremy

    Following some advice given here and in the mysql documentation, I’m setting up 3 keycaches. When I assign tables to a keycache, is that permanent or is that information lost when I restart the server or daemon? Also, is there a way to tell which keycache a table is assigned to currently?

    November 18, 2008 at 10:00 pm
  • yashesh


    I changed the parameter – innodb_log_file_size and many of mysql databases were giving lots of errors

    mysqlcheck would give errors
    error : Incorrect information in file: ‘./db1/civicrm_price_set_entity.frm’

    mysql> desc access;
    ERROR 1033 (HY000): Incorrect information in file: ‘./db1/access.frm’
    mysql> exit;

    mysqldump: Got error: 1033: Incorrect information in file: ‘./db1/access.frm’ when using LOCK TABLES

    Surprising thing is that of the above 3, only civicrm_price_set_entity is an innodb table. The other 2 are myisam.
    Finally after a lot of searcing i came across this very informative post –


    i’ll have to study a bit more deeper as to how to change the parameter innodb_log_file_size but it looks like it’s not as easy as
    editing the my.cnf file and restarting mysql.


    January 30, 2009 at 6:22 am
  • Baron Schwartz

    You have to move the old log files away. InnoDB is disabled in your server right now.

    January 30, 2009 at 6:42 am
  • kuber shrestha

    I am using Mysql server version 4.1.20
    and i in my server there are almost 10 databases but 2 databases running frequently. One has 40 tables and other has 120 tables. and they contains 133478 rows in each table.

    Mysql configuration is as follows:::

    [root@crm ~]$ vi /etc/my.cnf
    # Default to using old password format for compatibility with mysql 3.x
    # clients (those using the mysqlclient10 compatibility package).




    My Problem is that, day by day i see that the number of slow queries is increasing on.

    mysql> \s
    mysql Ver 14.7 Distrib 4.1.20, for redhat-linux-gnu (i686) using readline 4.3

    Connection id: 303745
    Current database: office_new
    Current user: root@localhost
    SSL: Not in use
    Current pager: stdout
    Using outfile: ”
    Using delimiter: ;
    Server version: 4.1.20
    Protocol version: 10
    Connection: Localhost via UNIX socket
    Server characterset: latin1
    Db characterset: latin1
    Client characterset: latin1
    Conn. characterset: latin1
    UNIX socket: /var/lib/mysql/mysql.sock
    Uptime: 72 days 19 hours 45 min 58 sec

    Threads: 1 Questions: 10163302 Slow queries: 149 Opens: 149457 Flush tables: 1 Open tables: 64 Queries per second avg: 1.615

    Please suggest me how to increase the performance of my server???? There are almost 20-30 user’s online each time.

    Please suggest me

    My email address is kuberstha@subisu.net.np

    June 22, 2009 at 1:35 am
  • MySQL Newbie

    Hi Peter,

    These tips definately sound great from the number of responses that you have got ! I am not really a DBA but have been using oracle for 8+ years now, I am more of a BI engineer who knows to use SQL and write fairly complex queries.
    I am very intrested in learning MySQL and perfromance tunning in MySQL from a reporting standpoint, ie to optimise the database (datawarehouse) for reporting.
    Would you be kind enough to provide me with a starting point ? some website which starts with the basics of tunning ? (once again I am not a DBA but am a BI engineer)

    (I am able to google and get way too many links and get easily lost -:)

    Thanks in Advance !

    June 29, 2009 at 2:43 pm
  • MySQL Newbie

    For example, I found this link on google http://www.mysql.com/why-mysql/performance/
    But it has so many articles and documents within and so was not sure what would be the right start and best bet from a time line perspective.

    Thanks again !

    June 29, 2009 at 2:49 pm
  • Kuber Shrestha

    Please Anyone suggest me how to increase the performance of my MYSQL server. Day by day the number of slow queries are increasing on!….

    Threads: 1 Questions: 10163302 Slow queries: 149 Opens: 149457 Flush tables: 1 Open tables: 64 Queries per second avg: 1.615


    June 29, 2009 at 10:16 pm
  • MySQL Newbie

    If I may ask you a basic question please ?
    How do you get these stats ? I mean from where ? (I am a newbie-:)

    Hope some expert helps you with your question !


    June 30, 2009 at 11:32 am
  • Kuber Shrestha

    These are mysql configuration and it is found in my.ini or my.cnf which is the base of mysql configuration.
    in linux you can view this file in this location

    July 1, 2009 at 12:37 am
  • MySQL Newbie

    Thanks Kuber !

    July 2, 2009 at 12:14 pm
  • Wagner Bianchi

    D’you consider “misc” like what, when treat about the functions of innodb_additional_mem_pool_size? I’ve used this variable to tune server to alocate dictionary cache…is this true?

    September 9, 2009 at 7:26 pm
  • aftab

    im running my chat server at centos with 3.5 gb ram , i observered there are round about 100 queries per second can you please guess some important parameteres and their values for my server that can increase speed of mysql .. currently it is going slower and slower as the users increasing

    October 13, 2009 at 7:17 pm
  • odeng

    Hi all,

    I really need your help on finding the solution for my problems. Fyi, i’m using 2 X quad core processor with 8gb of RAM. This server is a dedicated database server. So, my problems are, the mysql process always use 1 cpu core at 1 time and it used 100% of the cpu resource. I’am not sure why it happen like it. Below are my server ‘TOP’ status, as you can see cpu4 use 100% usage while others like at idle state.

    top – 18:27:53 up 103 days, 7:14, 3 users, load average: 1.10, 1.07, 1.02
    Tasks: 191 total, 1 running, 190 sleeping, 0 stopped, 0 zombie
    Cpu0 : 0.0% us, 0.3% sy, 0.0% ni, 99.7% id, 0.0% wa, 0.0% hi, 0.0% si
    Cpu1 : 0.0% us, 0.0% sy, 0.0% ni, 99.3% id, 0.7% wa, 0.0% hi, 0.0% si
    Cpu2 : 0.3% us, 0.0% sy, 0.0% ni, 99.7% id, 0.0% wa, 0.0% hi, 0.0% si
    Cpu3 : 0.0% us, 0.0% sy, 0.0% ni, 98.6% id, 1.4% wa, 0.0% hi, 0.0% si
    Cpu4 : 100.0% us, 0.0% sy, 0.0% ni, 0.0% id, 0.0% wa, 0.0% hi, 0.0% si
    Cpu5 : 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si
    Cpu6 : 0.0% us, 0.0% sy, 0.0% ni, 100.0% id, 0.0% wa, 0.0% hi, 0.0% si
    Cpu7 : 0.0% us, 0.0% sy, 0.0% ni, 99.7% id, 0.3% wa, 0.0% hi, 0.0% si
    Mem: 8165752k total, 8077196k used, 88556k free, 493192k buffers
    Swap: 4096532k total, 276k used, 4096256k free, 6326856k cached

    11395 mysql 16 0 100 39700:41 2.2 706m 172m 4764 S mysqld

    Below is my.cnf configuration file

    # Default to using old password format for compatibility with mysql 3.x
    # clients (those using the mysqlclient10 compatibility package)
    key_buffer = 384M
    max_allowed_packet = 1M
    table_cache = 512
    sort_buffer_size = 2M
    read_buffer_size = 2M
    read_rnd_buffer_size = 8M
    myisam_sort_buffer_size = 64M
    thread_cache_size = 8
    query_cache_size = 32M
    log_queries_not_using_indexes = On

    innodb_data_home_dir = /var/lib/mysql/
    #innodb_data_file_path = ibdata1:100M:autoextend
    set-variable = innodb_buffer_pool_size=100M
    set-variable = innodb_additional_mem_pool_size=10M

    # Try number of CPU’s*2 for thread_concurrency
    thread_concurrency = 16



    key_buffer = 256M
    sort_buffer_size = 256M
    read_buffer = 2M
    write_buffer = 2M

    key_buffer = 256M
    sort_buffer_size = 256M
    read_buffer = 2M
    write_buffer = 2M


    December 15, 2009 at 3:57 am
    • Baron Schwartz

      Odeng, the comments aren’t a place where we answer specific questions like that. If you really need help, we provide consulting on a paid basis. If you are looking for free help, you should post your question in a forum or mailing list.

      December 15, 2009 at 2:10 pm
  • Barbon

    Hi, I have a question. Does the settings on the post above are up to date ? I didn’t see last update on the article.

    Think you

    January 8, 2010 at 6:26 pm
  • cnizz

    Thanks this has been a big help. So on a dedicated MySQL server with 12 GB of RAM your saying the key_buffer_size should be set to about 3 GB? Right now its set at 512 MB…I’m slowly bumping it up by 512 MB every few days to gage performance. Please advise.

    September 14, 2010 at 4:27 pm
  • Wagner Bianchi


    I think that you must fit key_buffer_size memory space with all its tables indexes, as much as you can. SHOW VARIABLES LIKE ‘key%’ will show you all key_buffer_size status variables and than you’ll have an idea as you can proceed to configure key_buffer variable. Attention to a point: increase arbitrarily key_buffer variable will cause bad performance. Study and adjust it better as possible. Max 4GB, ok?


    September 14, 2010 at 4:47 pm
  • benhur

    Daer sir,

    Kill 20509 unauthenticated user 89.x.x.x:2501 None Connect Reading from net —

    I have already added the skip-name-resolve, skip-host-cache, and skip-locking option to my.cnf. As a added measure I have already added the IP Address to the /etc/hosts and the privileges for the user and IP address has also been granted in the database already.

    still problem is there can any abody please help

    Please help.


    April 8, 2011 at 5:37 am
  • Wagner Bianchi

    Normally, I have been adding skip-name-resolve on both sides, on both MySQL Servers involved on a remote connection.

    ERRATA on my last interaction:

    SHOW VARIABLES LIKE ‘key%’ will show you all variables involved in maintain key_buffer_size internal system and SHOW STATUS LIKE ‘key%’ will show you MySQL key_buffer_size status variables what is the snapshot of key_buffer behavior.

    April 8, 2011 at 6:00 am
  • Gustavo Navarro

    Be advised,
    when changing the values of variables
    innodb_log_file_size and innodb_log_buffer_size
    you must delete the file ib_logfile0 and probably ib_logfile1 too.
    otherwise it will not open the tables notifying: .frm file corrupted

    August 19, 2011 at 8:42 am
  • Budi Santoso

    I migrated our myISAM engine to InnoDB Engine and the performance is so poor after that and did some performance tuning based on above guidance. Now our MYSQL database is running faster and have a better performance.

    Thank for sharing

    December 15, 2011 at 11:41 pm
  • Prinzhorn

    Thanks for your tips.

    BUT: Please add a big warning that just changing “innodb_log_file_size” is not enough (see other comments for more info)! Since this post still ranks very high it would be important. Otherwise people like me will update their my.cnf and certainly the production site goes down 😉

    April 15, 2012 at 2:15 pm
  • Tariq Masood

    Dear All

    I developed an application of attendance system in Java and MySQL.
    When I get the attendance register of five employees it is working fine and report is opened.
    But when I send the command for more than five employees then database is disconnected
    with my application. The error is given below.

    Because there are several queries with while loop in my application.

    I request to all please help me to resolve the issue.
    I shall be thankful to you.


    Tariq Masood

    SQLException: Communications link failure due to underlying exception:


    MESSAGE: java.net.BindException: Address already in use: connect


    java.net.SocketException: java.net.BindException: Address already in use: connect
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
    at com.mysql.jdbc.MysqlIO.(MysqlIO.java:276)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2641)
    at com.mysql.jdbc.Connection.(Connection.java:1531)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
    at java.sql.DriverManager.getConnection(DriverManager.java:579)
    at java.sql.DriverManager.getConnection(DriverManager.java:243)
    at biopayroll.jdbcConnection.myStringGet(jdbcConnection.java:258)
    at biopayroll.rep_emp_attendance_register.get_gh_holiday(rep_emp_attendance_register.java:693)
    at biopayroll.rep_emp_attendance_register.jButton4ActionPerformed(rep_emp_attendance_register.java:311)
    at biopayroll.rep_emp_attendance_register.access$300(rep_emp_attendance_register.java:33)
    at biopayroll.rep_emp_attendance_register$4.actionPerformed(rep_emp_attendance_register.java:250)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6504)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6269)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4860)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4686)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2713)
    at java.awt.Component.dispatchEvent(Component.java:4686)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
    at java.awt.EventQueue.access$000(EventQueue.java:101)
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:680)
    at java.awt.EventQueue$4.run(EventQueue.java:678)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)


    April 28, 2012 at 4:16 am
  • JMaldonado

    Hello everyone;

    I have a server with this configuration:
    2x Intel Xeon 2.53 GHz
    64GB RAM
    4x 80 GB SSD MLC
    CentOS 5 x 64 bits
    RAID-5 HW

    In this server is installing MySql 5.5.21 and the sorftware has the following settings:
    init_connect=SET CHARACTER SET utf8

    max_connections = 1000
    wait_timeout = 60
    thread_concurrency = 2
    max_allowed_packet = 1M

    [Slow Querys]
    #log-slow-queries = /var/log/mysqlslowq.log
    #long_query_time = 5

    query_cache_type = 1
    query_cache_size = 64M
    query_cache_limit = 64M
    thread_cache_size = 70
    table_cache = 2048
    table_open_cache = 512

    join_buffer_size = 32M
    key_buffer_size = 640M
    myisam_sort_buffer_size = 64M
    sort_buffer_size = 4M
    read_rnd_buffer_size = 12M
    read_buffer_size = 4M

    server-id = 1
    server-id = 1
    expire_logs_days = 5
    max_binlog_size = 100M

    server-id = 1
    expire_logs_days = 5
    max_binlog_size = 100M


    The problem that we have is when conect to phpmyadmin and the system return to us that we have had 152 conections and this value is the max conection; when we have setting this parameters in 1000; so when I run the tuner script this one tell me that I have get the max connection (152) when I have set this parameter at 1000.

    Could any one gime me some advice or tell were is the wrong of theses settings?

    What I have to do to the system take correctly the settings?

    Thanks a lot for any comments.

    October 8, 2012 at 10:23 am
  • Michael

    I am working with MyISAM tables inserting millions of rows on Windows. MySQL writes to disk using very small I/O chunks. I am using a simple script inserting data into a table and monitoring disk I/O and I see that every I/O is 13 bytes. There is millions of small I/Os writtten to MYD file with sequentially increasing offset. Is there a way to increase the size of write I/O when insterting data into MyISAM tables? For example, instead of writing to disk every single row to write data by much larger blocks.

    Thank you

    November 30, 2012 at 1:34 pm
  • Aptitude

    innodb_buffer_pool_size was the actual thing I was searching for, search finally ends at your blog. Thanks a lot for such kind help. keep it up. thanks again

    August 7, 2013 at 2:56 am
  • Alejandro Stendelis

    Sorry for my bad english.
    I have a Managed VPS server (DV4 on MT).
    2GB Ram
    64-bit CentOS 6, MySQL 5.5 & PHP 5.4
    I run an application that takes an xml and inserts to the database are about 400,000 insertions per hour.
    In the next hour the system drop the database data and inserts again, this happens in the backend
    In the frontend of the website are connected near to 1000 users per hour, and mysql work is minimal.
    My experience with MySQL parameters is very low.
    But I need help tuning my MySQL to make it work better in the backend.
    I show my configuration and the results of mysqltuner.pl and tuning-primer.sh

    # Basic settings
    user = mysql
    datadir = /var/lib/mysql
    socket = /var/lib/mysql/mysql.sock
    # Security settings
    local-infile = 0
    symbolic-links = 0
    # Memory and cache settings
    query_cache_type = 1
    query_cache_size = 98M
    query_cache_limit = 24M
    thread_cache_size = 24
    table_cache =12
    tmp_table_size = 256M
    max_heap_table_size = 48M
    join_buffer_size = 12M
    key_buffer_size = 460M
    max_connections = 200
    wait_timeout = 3600
    # Innodb settings
    innodb_buffer_pool_size = 256M
    innodb_additional_mem_pool_size = 64M
    innodb_log_buffer_size = 3M
    innodb_thread_concurrency = 6
    # Basic safe settings
    log-error = /var/log/mysqld.log
    pid-file = /var/run/mysqld/mysqld.pid
    ### Log slow queries ###
    log-slow-queries = mysqld-slow.log
    # Duration a query must run (in seconds) to get logged
    long_query_time = 1

    >> MySQLTuner 1.2.0 – Major Hayden
    >> Bug reports, feature requests, and downloads at http://mysqltuner.com/
    >> Run with ‘–help’ for additional options and output filtering
    ——– General Statistics ————————————————–
    [–] Skipped version check for MySQLTuner script
    [OK] Currently running supported MySQL version 5.1.54
    [OK] Operating on 64-bit architecture
    ——– Storage Engine Statistics ——————————————-
    [–] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
    [–] Data in MyISAM tables: 1G (Tables: 304)
    [–] Data in InnoDB tables: 2M (Tables: 173)
    [!!] Total fragmented tables: 191
    ——– Security Recommendations ——————————————-
    [OK] All database users have passwords assigned
    ——– Performance Metrics ————————————————-
    [–] Up for: 21h 8m 26s (5M q [75.629 qps], 41K conn, TX: 1B, RX: 28B)
    [–] Reads / Writes: 0% / 100%
    [–] Total buffers: 929.0M global + 14.6M per thread (200 max threads)
    [!!] Maximum possible memory usage: 3.8G (110% of installed RAM)
    [OK] Slow queries: 0% (12/5M)
    [OK] Highest usage of available connections: 4% (8/200)
    [OK] Key buffer size / total MyISAM indexes: 460.0M/410.3M
    [OK] Key buffer hit rate: 99.4% (64M cached / 372K reads)
    [OK] Query cache efficiency: 93.6% (469K cached / 501K selects)
    [OK] Query cache prunes per day: 0
    [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 1K sorts)
    [!!] Joins performed without indexes: 263
    [OK] Temporary tables created on disk: 22% (1K on disk / 7K total)
    [OK] Thread cache hit rate: 99% (8 created / 41K connections)
    [!!] Table cache hit rate: 0% (12 open / 11K opened)
    [OK] Open file limit used: 2% (24/1K)
    [OK] Table locks acquired immediately: 99% (41K immediate / 41K locks)
    [OK] InnoDB data size / buffer pool: 2.8M/256.0M
    ——– Recommendations —————————————————–
    General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours – recommendations may be inaccurate
    Reduce your overall MySQL memory footprint for system stability
    Enable the slow query log to troubleshoot bad queries
    Adjust your join queries to always utilize indexes
    Increase table_cache gradually to avoid file descriptor limits
    Variables to adjust:
    *** MySQL’s maximum memory usage is dangerously high ***
    *** Add RAM before increasing MySQL buffer variables ***
    join_buffer_size (> 12.0M, or always use indexes with joins)
    table_cache (> 12)

    – By: Matthew Montgomery –
    MySQL Version 5.1.54 x86_64
    Uptime = 0 days 21 hrs 7 min 34 sec
    Avg. qps = 75
    Total Questions = 5753619
    Threads Connected = 2
    Warning: Server has not been running for at least 48hrs.
    It may not be safe to use these recommendations
    To find out more information on how each of these
    runtime variables effects performance visit:
    Visit http://www.mysql.com…e/advisors.html
    for info about MySQL’s Enterprise Monitoring and Advisory Service
    The slow query log is NOT enabled.
    Current long_query_time = 10.000000 sec.
    You have 12 out of 5753646 that take longer than 10.000000 sec. to complete
    Your long_query_time seems to be fine
    The binary update log is NOT enabled.
    You will not be able to do point in time recovery
    See http://dev.mysql.com…e-recovery.html
    Current thread_cache_size = 24
    Current threads_cached = 6
    Current threads_per_sec = 0
    Historic threads_per_sec = 0
    Your thread_cache_size is fine
    Current max_connections = 200
    Current threads_connected = 2
    Historic max_used_connections = 8
    The number of used connections is 4% of the configured maximum.
    You are using less than 10% of your configured max_connections.
    Lowering max_connections could help to avoid an over-allocation of memory
    See “MEMORY USAGE” section to make sure you are not over-allocating
    Current InnoDB index space = 2 M
    Current InnoDB data space = 2 M
    Current InnoDB buffer pool free = 96 %
    Current innodb_buffer_pool_size = 256 M
    Depending on how much space your innodb indexes take up it may be safe
    to increase this value to up to 2 / 3 of total system memory
    Max Memory Ever Allocated : 997 M
    Configured Max Per-thread Buffers : 2.85 G
    Configured Max Global Buffers : 881 M
    Configured Max Memory Limit : 3.71 G
    Physical Memory : 3.42 G
    Max memory limit exceeds 90% of physical memory
    Current MyISAM index space = 410 M
    Current key_buffer_size = 460 M
    Key cache miss rate is 1 : 171
    Key buffer free ratio = 81 %
    Your key_buffer_size seems to be fine
    Query cache is enabled
    Current query_cache_size = 98 M
    Current query_cache_used = 25 M
    Current query_cache_limit = 24 M
    Current Query cache Memory fill ratio = 25.84 %
    Current query_cache_min_res_unit = 4 K
    Your query_cache_size seems to be too high.
    Perhaps you can use these resources elsewhere
    MySQL won’t cache query results that are larger than query_cache_limit in size
    Current sort_buffer_size = 2 M
    Current read_rnd_buffer_size = 256 K
    Sort buffer seems to be fine
    Current join_buffer_size = 12.00 M
    You have had 263 queries where a join could not use an index properly
    join_buffer_size >= 4 M
    This is not advised
    You should enable “log-queries-not-using-indexes”
    Then look for non indexed joins in the slow query log.
    Current open_files_limit = 1024 files
    The open_files_limit should typically be set to at least 2x-3x
    that of table_cache if you have heavy MyISAM usage.
    Your open_files_limit value seems to be fine
    Current table_open_cache = 12 tables
    Current table_definition_cache = 256 tables
    You have a total of 500 tables
    You have 12 open tables.
    Current table_cache hit rate is 0%
    , while 100% of your table cache is in use
    You should probably increase your table_cache
    You should probably increase your table_definition_cache value.
    Current max_heap_table_size = 48 M
    Current tmp_table_size = 256 M
    Of 5775 temp tables, 22% were created on disk
    Effective in-memory tmp_table_size is limited to max_heap_table_size.
    Created disk tmp tables ratio seems fine
    Current read_buffer_size = 128 K
    Current table scan ratio = 5654 : 1
    You have a high ratio of sequential access requests to SELECTs
    You may benefit from raising read_buffer_size and/or improving your use of indexes.
    Current Lock Wait ratio = 1 : 6979
    Your table locking seems to be fine

    November 14, 2013 at 11:19 am
  • Tom Diederich

    Hi Alejandro,

    This post is actually 7 years old – and your question is very detailed. The best place to get advice for issues like yours is the Percona discussion forums – that is where you can ask for help from not only your peers but also Percona experts who participate on some of the posts. Here’s the url: https://www.percona.com/forums/

    November 15, 2013 at 8:55 am
  • Alejandro Stendelis


    November 15, 2013 at 11:34 am
  • Sonu

    I was using ISAM tables with default settings in my website http://www.playquiz2win.com. Never thought about using INNODB tables. Your post on key_buffer_size in case of ISAM tables is wonderful. Your whole article is very informative.

    September 3, 2014 at 7:21 am
  • Shiro

    Sorry for my bad English

    I want to know specific formula and accurate for that parameters
    Example: how can you set the values of key_buffer_size v.v…

    Thanks so much!

    March 5, 2015 at 3:05 am
  • sok123

    My mysql server always shutdown time
    Can you help me ?

    October 7, 2015 at 12:47 am
  • Anup

    Hi…Please elaborate the difference between Mysqli and PDO in another post..

    November 8, 2016 at 5:40 am
  • website

    thanks for sharing this amazing posting.

    September 11, 2017 at 1:55 am
  • Utpal

    Thanks for these awesome tricks. Please share more such posts.

    October 13, 2018 at 3:14 am
  • Byari

    Thank you for this useful post. Recently I started working on MSSQL to MySql conversion. This post will help me to understand MySql.

    April 22, 2019 at 3:15 am
  • Bhuvan

    I am using innodb tables for my website. Till now, I was using default settings. I got a lead from your article that we can fine tune the variables that you have mentioned for optimum performance. Thanks for the information.

    August 17, 2019 at 1:33 pm
  • eHow Hindi

    Hi, I have a question. Does the settings on the post above are up to date ?

    Thank you

    December 1, 2019 at 12:03 am
  • LyricsAsk

    Thanks a lot.

    December 1, 2019 at 12:05 am
  • Lyrics

    This post is 8 years old but is very detailed, and useful. I got some clear insights about MYSQL, thanks a lot.

    January 18, 2020 at 12:02 am
  • hiren shekhada

    Thanks for these awesome tricks. Please share more such posts.

    February 15, 2020 at 2:08 pm
  • Mia

    Thnks guyz

    April 18, 2020 at 8:18 am
  • akki

    now i understand this thanks for sharing

    April 22, 2020 at 3:25 am
  • trangtriqc

    I think innodb_buffer_pool_instances option is also extremely important if we want to tuning performance engine InnoDB

    May 5, 2020 at 3:51 am
  • rgg rfg

    I was using ISAM tables with default settings in my website http://www.extragyan.com. Never thought about using INNODB tables. Your post on key_buffer_size in case of ISAM tables is wonderful.

    May 11, 2020 at 12:05 am
  • Roshan Singh

    Thank you for this useful post. Recently I started working on MSSQL to MySql conversion. This post will help me to understand MySql.

    July 1, 2020 at 2:11 pm

Comments are closed.

Use Percona's Technical Forum to ask any follow-up questions on this blog topic.