An open API service indexing awesome lists of open source software.

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

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