Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metrics for tables #1024

Closed
bazmap opened this issue Apr 29, 2024 · 3 comments
Closed

Add metrics for tables #1024

bazmap opened this issue Apr 29, 2024 · 3 comments

Comments

@bazmap
Copy link

bazmap commented Apr 29, 2024

Proposal

Adding metrics for tables is important as it allows you to monitor what causes troubles into your database.

You can use this query to have informations over your tables :
Adding the result of this query into the metrics collected :

SELECT 
	pg_stat.*,
	pg_statio.*,
	pgc.*,
	pg_relation_size(pgc.oid)
FROM pg_catalog.pg_stat_user_tables AS pg_stat 
LEFT JOIN pg_catalog.pg_statio_user_tables AS pg_statio
	ON pg_statio.relid = pg_stat.relid
LEFT JOIN pg_catalog.pg_class AS pgc 
	ON pgc.oid = pg_stat.relid
;

Why ?

Because you can tracks each table into the database wich helps you to monitor what table can cause trouble.
Some examples :

  • seq_scan over seq_tup_read allows you to know if you need index
  • Which table haven't been autovacuumed.
  • The size of each relations (aka table) : size, nb of tuples, nb of pages
  • Number of deadrows

This need to be desactivated as this request return as many line as the number of table into the database.

@bazmap
Copy link
Author

bazmap commented Apr 29, 2024

Ok I think thats because the pg_stat_user_tables and the pg_statio_user_tables is not activated by default... (the doc says that this is activated by default...)
I will give it a try and closed this issue or change what I need.
Sorry

@bazmap
Copy link
Author

bazmap commented Apr 30, 2024

Ok these metrics are implemented but the last postgres_exporter doesn't show these on PostgreSQL 11 - Windows 11.
I check other tests and will give you more details

@bazmap
Copy link
Author

bazmap commented Apr 30, 2024

Ok I found the trouble : I was connected to the "postgres" database which doesn't contain anything... If I specify another databse in the same instance, I have my statistics.
The documentation should indicate that the data collected are only for one database and not for the whole instance.
This is more or less link to the #999 issue.
I will close this one but keep this explaination for other people.

@bazmap bazmap closed this as completed Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant