Mysql innodb caches

From wikinotes
Revision as of 04:19, 8 September 2022 by Will (talk | contribs) (Created page with "= Buffer Pool (in-memory) = <blockquote> == Basics == <blockquote> Stores adaptive-hash-table (in-memory db caching), row data, write buffers, locks etc. <syntaxhighlight lang="mysql"> # pages in buffer pool (memory) (16KB/page ?) select count(*) from information_schema.innodb_buffer_page; # ========== # configuration # =========== # bytes per chunk show variables like 'innodb_buffer_pool_chunk_size'; # bytes allowed for buffer pool show variables like 'innodb_buffe...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Buffer Pool (in-memory)

Basics

Stores adaptive-hash-table (in-memory db caching), row data, write buffers, locks etc.

# pages in buffer pool (memory) (16KB/page ?)
select count(*) from information_schema.innodb_buffer_page;


# ==========
# configuration
# ===========

# bytes per chunk
show variables like 'innodb_buffer_pool_chunk_size';

# bytes allowed for buffer pool
show variables like 'innodb_buffer_pool_size';

Adaptive Hash Index

The AdaptiveHashIndex, when enabled is designed to make innodb behave like an in-memory database, crossed with an LRU cache. The mysql docs specifically call out disabling it interactively for benchmarking, and document that the table is emptied immediately when this feature is disabled.

If you're looking to evaluate query cost without caching, this is likely what you want to disable.

# interactive
SET GLOBAL innodb_adaptive_hash_index=OFF;

# CLI
mysqld --skip-innodb-adaptive-hash-index

You could further scale back buffering by configuring mysql with a small buffer_pool_size (untested)

# my.cnf
[mysqld]
innodb_buffer_pool_size=1M
key_buffer_size=8
query_cache_type=0

InnoDB: Memcached Plugin

If this is enabled, you can use very fast get/set key-value operations instead of SQL queries (which require parsing, optimization).
The memcached instance is embedded in mysql, no separate process required.

This is not used to improve the BufferPool's AdaptiveHashTable for regular SQL queries,
it exposes an entirely different interface.

Disk

InnoDB: Data Dictionary

Caches table metadata (ex. indexes, tables, columns)

https://dev.mysql.com/doc/refman/5.7/en/innodb-data-dictionary.html