B
B
bood2015-02-25 19:47:30
PostgreSQL
bood, 2015-02-25 19:47:30

PostgreSQL. How to count the number of insert operations in a table?

Is it possible to count the number of INSERTs into a table over a certain period of time?
As far as I understand, information about all transactions is stored in logs. Is it possible to extract statistics from them using SQL?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Incher, 2015-02-26
@Incher

I won’t tell you about the log, but as an option, you can create a trigger www.postgresql.org/docs/9.1/static/sql-createtrigg... on INSERT and fix the date of each INSERT in some table

A
Aristarkh Zagorodnikov, 2015-02-28
@onyxmaster

According to the data that has already passed - only by manual analysis of WAL, and then it is also rotated.
If there is any monitoring or you can make a background task:

select "n_tup_ins" from "pg_catalog"."pg_stat_user_tables" where "relname" = '<tablename>';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question