Skip to content

Instantly share code, notes, and snippets.

@rodo
Created March 18, 2024 10:35
Show Gist options
  • Select an option

  • Save rodo/4d6c3d753c0566286408b99484cb0276 to your computer and use it in GitHub Desktop.

Select an option

Save rodo/4d6c3d753c0566286408b99484cb0276 to your computer and use it in GitHub Desktop.
Follow the user objects stats in postgresql
-- first create a schema to store your new table
CREATE SCHEMA dba;
-- create the table
CREATE TABLE dba.log_stat (LIKE pg_stat_user_tables);
--- add a column to timestamp the figures
ALTER TABLE dba.log_stat ADD COLUMN eventtime timestamp with time zone default now();
--- last action insert the stats in the table
INSERT INTO dba.log_stat SELECT * FROM pg_stat_user_tables;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment