Re: How to know if a database has changed

Поиск
Список
Период
Сортировка
От Jaime Casanova
Тема Re: How to know if a database has changed
Дата
Msg-id CAJGNTePV-Aw05t-ApafUyeMPqVyw+oUTY4i02bKV+wm3r2ToLQ@mail.gmail.com
обсуждение исходный текст
Ответ на How to know if a database has changed  (marcelo <marcelo.nicolet@gmail.com>)
Список pgsql-general
On 11 December 2017 at 11:48, marcelo <marcelo.nicolet@gmail.com> wrote:
> The installation I'm planning will manage several databases, but not all of
> them will change every day.
> In order to planning/scripting the pg_dump usage, I would need to know which
> databases had some change activity at the end of some day.
> How can it be done?

Hi,

Just keep a snapshot of pg_stat_database view
(https://www.postgresql.org/docs/10/static/monitoring-stats.html#PG-STAT-DATABASE-VIEW)

At the end of the day compare the counters of
tup_inserted/tup_updated/tup_deleted or just xact_commit/xact_rollback
if the snapshot you kept is different from the current values there
were modifications on the database.

Maybe there are some caveats, for example CREATE commands are included
because they insert data in table catalogs? i don't know, is up to you
to check that

-- 
Jaime Casanova                      www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


В списке pgsql-general по дате отправления:

Предыдущее
От: James Keener
Дата:
Сообщение: Re: How to know if a database has changed
Следующее
От: Andreas Kretschmer
Дата:
Сообщение: Re: How to know if a database has changed