Skip to content

Investigate why several tables are analyzed several times per minute

From Andrew N. in production#3875 (comment 525184788)

Considering that table statistics are at the critical to understanding this issue, I feel it's important to understand why several mostly-CI-related tables were being analyzed several times a minute in the immediate run-up to this incident. Is there ever a valid reason to be running ANALYZE multiple times a minute on large tables in production?

image

https://thanos.gitlab.net/graph?g0.range_input=1d&g0.max_source_resolution=0s&g0.expr=changes(pg_stat_user_tables_last_analyze%7Bfqdn%3D%22patroni-03-db-gprd.c.gitlab-production.internal%22%7D%5B5m%5D)&g0.tab=0

From Andrew N. in production#3875 (comment 525188564)

Also, there did not appear to be a particularly high rate of change on any of these tables (nor any other tables for that matter) around the time of the incident.

image

source

Why are these tables getting analyzed so frequently @Finotto?

From Andreas B. in production#3875 (comment 525196040)

Autovacuum operations seem to have a similar rate for these tables (similar to the analyze ops).

We do have the same thresholds configured for auto-vacuum and auto-analyze (autovacuum_vacuum_scale_factor, autovacuum_vacuum_threshold and their _analyze_ friends), so this is also expected.

Edited by Marin Jankovski