https://github.com/kyleburton/pg-rowcount
Track row counts in PostgreSQL
https://github.com/kyleburton/pg-rowcount
Last synced: 10 months ago
JSON representation
Track row counts in PostgreSQL
- Host: GitHub
- URL: https://github.com/kyleburton/pg-rowcount
- Owner: kyleburton
- Created: 2013-08-17T21:26:04.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-09-04T12:10:15.000Z (over 12 years ago)
- Last Synced: 2025-01-29T06:48:54.494Z (12 months ago)
- Language: Shell
- Size: 113 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
Awesome Lists containing this project
README
h1. Track Rowcounts for PostgreSQL
This creates a 'rowcounts' schema, a function for enabling the triggers on a table, and the following two tables:
* rowcounts.counts
* rowcounts.count_metrics
The counts table maintains an accurate rowcount by table. The count_metrics table maintains a count of inserts and deletes aggregated by the following periods:
* year
* year, month
* year, month, day
* year, month, day, hour
* year, month, day, hour, minute
h2. Installation
To enable the row tracking triggers for a table, execute:
select rowcounts.track_rowcount_on('schema_name','table_name');
NB: calling this will lock the table in order to get an accurate initial count.
To disable row tracking, execute:
select rowcounts.stop_tracking_rowcount_on('schema_name','table_name');
h2. See Also
* "http://www.varlena.com/GeneralBits/120.php":http://www.varlena.com/GeneralBits/120.php
* "http://www.varlena.com/GeneralBits/49.php":http://www.varlena.com/GeneralBits/49.php
* "http://wiki.postgresql.org/wiki/Slow_Counting":http://wiki.postgresql.org/wiki/Slow_Counting
Structure, form and approaches taken from:
* "http://wiki.postgresql.org/wiki/Audit_trigger_91plus":http://wiki.postgresql.org/wiki/Audit_trigger_91plus
h2. TODO
* make the metrics tracking optional