Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How well do your tables fit in buffer pool

DZone's Guide to

How well do your tables fit in buffer pool

· Database Zone
Free Resource

Learn how to move from MongoDB to Couchbase Server for consistent high performance in distributed environments at any scale.

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.

Want to deliver a whole new level of customer experience? Learn how to make your move from MongoDB to Couchbase Server.

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 DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

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

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}