Over a million developers have joined DZone.

How well do your tables fit in buffer pool

· Database Zone

Build fast, scale big with MongoDB Atlas, a hosted service for the leading NoSQL database. Try it now! Brought to you in partnership with MongoDB.

In XtraDB we have the table INNODB_BUFFER_POOL_PAGES_INDEX which shows which pages belong to which indexes in which tables. Using thing information and standard TABLES table we can see how well different tables fit in buffer pool.
SQL:

1.
mysql> SELECT d.*,round(100*cnt*16384/(data_length+index_length),2) fit FROM (SELECT schema_name,table_name,count(*) cnt,sum(dirty),sum(hashed) FROM INNODB_BUFFER_POOL_PAGES_INDEX GROUP BY schema_name,table_name ORDER BY cnt DESC LIMIT 20) d JOIN TABLES ON (TABLES.table_schema=d.schema_name AND TABLES.table_name=d.table_name);
2.
+-------------+---------------------+---------+------------+-------------+--------+
3.
| schema_name | table_name | cnt | sum(dirty) | sum(hashed) | fit |
4.
+-------------+---------------------+---------+------------+-------------+--------+
5.
| db | table1 | 1699133 | 13296 | 385841 | 87.49 |
6.
| db | table2 | 1173272 | 17399 | 11099 | 98.42 |
7.
| db | table3 | 916641 | 7849 | 15316 | 94.77 |
8.
| db | table4 | 86999 | 1555 | 75554 | 87.42 |
9.
| db | table5 | 32701 | 7997 | 30082 | 91.61 |
10.
| db | table6 | 31990 | 4495 | 25681 | 102.97 |
11.
| db | table7 | 1 | 0 | 0 | 100.00 |
12.
+-------------+---------------------+---------+------------+-------------+--------+
13.
7 rows IN SET (26.45 sec)

You can also see in one of the cases the value shown is a bit over 100% - I am not sure where it comes from but more pages reported to belong to the table in buffer pool than on disk. Though it seems to work well enough for estimation purposes.

Now it's easier than ever to get started with MongoDB, the database that allows startups and enterprises alike to rapidly build planet-scale apps. Introducing MongoDB Atlas, the official hosted service for the database on AWS. Try it now! Brought to you in partnership with MongoDB.

Topics:

Published at DZone with permission of Peter Zaitsev, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}