Get tuple insertion time in existing table in PostgreSQL 9.3

I am running PostgreSQL 9.3 (in hot standby) on Ubuntu 14.04 LTS .

I would like to display the growth (e.g. the number of tuples) of the table over time. The table does not contain a "timestamp" column (or equivalent for historical reasons).

Is their way in PostgreSQL 9.3 request information about tuple insertion time in a table ?

+5
source share
1 answer

Performing a workaround can give you statistics on table growth over time. Postgres 9.3 has a feature called Statistics Collector . This can do the trick:

  • enable runtime statistics
  • create the desired analysis function using pg_stat_all_tables
    • indicate how many new tuples were inserted using n_tup_ins (see Table 27-5 pg_stat_all_tables View )
    • compute the difference with an older value to get the actual number of tuples inserted in a specific time frame

Or you can take a look at Zalando PGObserver .

Hope this helps.

+2
source

Source: https://habr.com/ru/post/1240836/


All Articles