November 28, 2014

How well do your tables fit in buffer pool

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.

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.

UPDATE: We have changed the Schema in newer Percona Server versions and this exact query will no more work. The correct query is described in this post

About Peter Zaitsev

Peter managed the High Performance Group within MySQL until 2006, when he founded Percona. Peter has a Master's Degree in Computer Science and is an expert in database kernels, computer hardware, and application scaling.

Comments

  1. Steve Jackson says:

    Peter, this query does not work on 5.5

    INNODB_BUFFER_POOL_PAGES_INDEX no longer contains schema_name column, so query fails on this.

    Do you have an updated version of the same query, but for rel 5.5?

    Cheers

    //Steve

  2. Jeffrey Gilbert says:

    That is awesome. Wish I had this sort of feature back in the day.

  3. Bash99 says:

    a generic version work with partitions

    SELECT d.*,round(100*cnt*16384/(data_length+index_length),2) fit
    FROM (SELECT schema_name,
    replace(substring_index(table_name, ‘#’, 3), ‘#mysql50#’, ”) as xtable_name,
    substring_index(table_name, ‘#’, -1) as partition_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.xtable_name);

  4. peter says:

    Bash99,

    Thanks. Great.

Speak Your Mind

*