This alert monitors the PostgreSQL
TOAST index cache hit ratio for a specific table in a database. A low hit ratio indicates a potential performance issue, as it means that a high number of cache misses are occurring. If you receive this alert, it suggests that your system is experiencing higher cache miss rates, which may lead to increased I/O load and reduced query performance.
TOAST (The Oversized-Attribute Storage Technique) is a technique used by PostgreSQL to handle large data values. It allows PostgreSQL to store large records more efficiently by compressing and storing them separately from the main table. The TOAST index cache helps PostgreSQL efficiently access large data values, and a high cache hit ratio is desired for better performance.
Run the following query in the PostgreSQL prompt to see the current hit ratio:
SELECT schemaname, relname, toastidx_scan, toastidx_fetch, 100 * (1 - (toastidx_fetch / toastidx_scan)) as hit_ratio
FROM pg_stat_all_tables
WHERE toastidx_scan > 0 and relname='${label:table}' and schemaname='${label:database}';
Inspect the queries running on the database to determine if any specific queries are causing excessive cache misses. Use pg_stat_statements
module to gather information on query performance.
work_mem
configuration valueIf the issue persists, consider increasing the work_mem
value in the PostgreSQL configuration file (postgresql.conf
). This parameter determines the amount of memory PostgreSQL can use for internal sort operations and hash tables, which may help reduce cache misses.
Remember to restart the PostgreSQL server after making changes to the configuration file for the changes to take effect.
Assess if the table design can be optimized to reduce the number of large data values or if additional indexes can be created to improve cache hit ratio.
Keep an eye on overall database performance metrics, such as query execution times and I/O load, to determine the impact of increased cache miss ratios on database performance.