Log PostgreSQL tuple counts after E2E runs
In gitlab#396649 (closed), we had difficulty tracking a performance regression because there were no logs that showed that a significant number of rows were being inserted into PostgreSQL.
If we had simply logged the output of this, this might have revealed an unusual amount of write activity:
gitlabhq_production=# select n_live_tup, n_dead_tup, relname from pg_stat_all_tables order by n_live_tup DESC, n_dead_tup DESC;
n_live_tup | n_dead_tup | relname
------------+------------+---------------------------------------------------------
2380510 | 0 | pm_package_version_licenses
2320969 | 9 | pm_package_versions
237860 | 762 | pm_packages
41144 | 0 | pg_attribute
38211 | 0 | pg_depend
6346 | 0 | pg_class
4157 | 0 | pg_trigger
4091 | 0 | pg_index
3340 | 0 | pg_type
<snip>
Alternatively, we could scrape postgres_exporter
for this data (curl http://localhost:9187/metrics
), but it may not be as straightforward to see the data. pg_total_relation_size_bytes
might tell us some info about the size used.
It seems we should enable per table stats:
postgres_exporter['per_table_stats'] = true
pg_stat_user_tables
metrics would have this info.
/cc: @jay_mccure @a_mcdonald
Edited by Stan Hu