Skip to content

Commit

Permalink
Postgres: Prioritize collection of size metrics on larger tables
Browse files Browse the repository at this point in the history
The `max_relations` parameter
(https://github.com/DataDog/integrations-core/blob/cf923f4aa3e63d/postgres/datadog_checks/postgres/data/conf.yaml.example#L160-L163)
limits the number of relations that metrics are collected on.
Previously, no order was specified, which meant that the metrics that
were reported depedended on the vagaries of Postgres. This change orders
the query by total table size because people are more likely to care
about size-related metrics for larger tables than for smaller ones.
There are exceptions, but even so, collecting metrics for the largest N
tables seems more useful than collecting metrics for an unspecified
subset of N tables.
  • Loading branch information
patbl committed Mar 4, 2022
1 parent 43a4638 commit 9b20f7c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion postgres/datadog_checks/postgres/relationsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
WHERE nspname NOT IN ('pg_catalog', 'information_schema') AND
nspname !~ '^pg_toast' AND
relkind = 'r' AND
{relations}""",
{relations}
ORDER BY pg_total_relation_size(C.oid) DESC""",
}

# The pg_statio_all_tables view will contain one row for each table in the current database,
Expand Down

0 comments on commit 9b20f7c

Please sign in to comment.