postgresql - Postgres: Best way to determine changes in table without scanning entire table -
i designing etl take incremental changes postgres table.
how detect whether table rows modified after last etl run without doing full table scan ?
i'd save stats , compare pg_stat_all_tables
that, eg ran sequentially:
t=# select schemaname,relname,n_tup_ins,n_tup_upd,n_tup_del pg_stat_all_tables relname = 'rapid_inserts'; schemaname | relname | n_tup_ins | n_tup_upd | n_tup_del ------------+--------------------+-----------+-----------+----------- public | rapid_inserts| 254681563 | 0 | 0 (1 row) time: 10.921 ms t=# select schemaname,relname,n_tup_ins,n_tup_upd,n_tup_del pg_stat_all_tables relname = 'rapid_inserts'; schemaname | relname | n_tup_ins | n_tup_upd | n_tup_del ------------+--------------------+-----------+-----------+----------- public | rapid_inserts| 254681569 | 0 | 0 (1 row) time: 10.980 ms
it means 6 rows inserted in barely second. same work updates , deletes...
Comments
Post a Comment