DEV Community

Ben Osborne
Ben Osborne

Posted on

MySQL : InnoDB : RAM

Are InnoDB tables held in RAM even if they are not frequently queried or at all?

How does MySQL work out which table to hold in memory etc?

For example, if I had 5 tables and all 5 were InnoDB, I query only two of the five tables, will the other three tables still be held in memory?

Discussion (5)

Collapse
anurbol profile image
Nurbol Alpysbayev • Edited on

Why do you think they are held in memory? They are not. MySQL stores data on disk. However, there is an in-memory mode, but it is off by default. However, if you enable it, the WHOLE DB will constantly will live in memory, i.e. if it has 3GB of data, you will have 3GB of RAM taken for that. That is from my experience.

Collapse
mrbenosborne profile image
Ben Osborne Author

Basically I have a 40gb table which is not accessed frequently however, I only have 10gb left of RAM, which made me think that it was holding that table.

Total server RAM is 61GB, AWS Aurora.

Collapse
anurbol profile image
Nurbol Alpysbayev • Edited on

Dian Fay may be correct about buffer pool. But I don't think it can take 50 Gb of RAM. Can it be your application that extracts data from DB and holds it in memory? I bet it is, especially if it is not Node.js or PHP app, but persistent daemon-like e.g. Java app.

Collapse
dmfay profile image
Dian Fay

You want to read about the buffer pool.

Collapse
mrbenosborne profile image
Ben Osborne Author

Thanks Dian,

I did but I still don’t understand fully.