If your Postgres database has a large number of relations (in the thousands), Datadog recommends adding collect_database_size_metrics: false to your instance configuration for that database. When this setting is disabled, the Agent will not run the function pg_database_size() to collect database size statistics, which has worse performance on instances with a large number of tables.
Additionally, if you partition your data across tables, such that table definitions are identical except for the name, this can result in a large number or normalized queries:
In these cases, track these queries as a single normalized query using the replace_digits option, so all metrics for those queries are rolled up into a single query:
SELECT*FROMdaily_aggregates_?
Add the replace_digits option to your database instance configuration in the Datadog Agent:
If you have queries that are relatively infrequent or execute quickly, raise the sampling rate by lowering the collection_interval value to collect samples more frequently.
Set the collection_interval in your database instance configuration of the Datadog Agent. The default value is 1 second and can be seen in the postgres/conf.yaml.example.