i have a mysql 5.6.19 on linux server, and it takes about 8 Gb of memory. That is much more than i expect.

There are about 150 db, each with 700 tables. All of them are innodb. We do not care about their safety.

SHOW ENGINE INNODB STATUS - Total memory allocated 4395630592. So i can't understand why mysql takes additional 3.5 Gb, any suggestions ?

innodb_log_buffer_size = 100M    

wait_timeout = 300  


2 Answers 2


There are many things that are wrong with your configuration and running status:

With your configuration, before running no query, you need 1.5 GB of static memory assignment- before the buffer pool is even used an no connection is performed. Most of it (1GB) goes to performance_schema, but there is still 500MB that are allocated (vs the 42k for the default configuration).

You also have quite some high number of temporary tables created (180 tables/s), half of them in memory -I would bet that the other 90 are created in memory, then on disk. That can account, in your setup, to up to 1.8 GB of temporary tables per second.

Your queries have a non-negligible amount of full joins and full table scans, reading randomly 26K rows per second and sorting 3K per second. In summary- you end up wasting lots of resources in read buffers, join buffers and sort buffers. And that is for 90 simultaneous connections. 90 is not a high number for MySQL, but you need more resources for the type of queries that you are executing- which examine lots of rows.

You say that you have 100K tables, which usually affects the InnoDB dictionary size (146M) and the open_table_cache. You have increased some of the caches, but I do not agree that that is the right way to proceed.

Aside from that, you have lots of connections using SHOW STATUS commands, typical from an ORM/framework. Not worrying in 5.6, where metadata commands do not update the InnoDB statistics automatically, but from that I can derive that the queries you are executing are not the most optimal ones.

So, my recommendations:

  • Turn down most of the memory-related, session-only or query-only variables (e.g. tmp_table_size)
  • Turn down table-cache related variables
  • Reduce the concurrency by setting up a pool of connections (or reconfigure the current one). This will allow you to turn down max_connections without affecting the application throughput.

These ones will increase latency, but that is needed in order to increase the concurrency. If you want more concurrency with the same memory resources you will have to split your tables on several servers (aka sharding). In general, there are many things that I do not like from your configuration file, but I am not bold enough to tell you to change them without evaluating them myself.

  • Turn off performance_schema (it will save you 1GB of memory for your configured number of connections)
  • Fix your queries and start using indexes. Or create the appropriate indexes. This is probably the first step.
  • Avoid using MySQL- Without seeing your queries, something tells me that most of them could be easily cached at application or middleware layer. 5.6 even comes with a free memcached server!
  • Watch for the rollbacks you are executing (1 was running at the time of the statistics gathering). Rollbacks are very expensive resource-wise (memory and CPU).

For more detailed information, I would need to perform a query audit.


Performance Schema allocates memory at start up based upon your set values. It takes up all memory it could need for monitoring right away. This means it doesn't matter if there are for example 5 or 50 connections, just that there are 400 allowed.

If you don't use/need Performance Schema, disable it:

performance_schema = off

Documentation on Performance Schema: http://dev.mysql.com/doc/refman/5.6/en/performance-schema.html

  • thanks, but it didn't solve my problem
    – Andrey
    Commented Oct 2, 2014 at 6:36
  • Meaning your memory consumption didn't change at all? How much is still 'unaccounted' for?
    – Acrklor
    Commented Oct 2, 2014 at 9:20
  • memory usage was decrease, but still high. Right now mysql takes 7.2Gb for 91 connections
    – Andrey
    Commented Oct 2, 2014 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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