Is it nonsense (read: stupid) to keep count of child entries via triggers and a custom table?

Поиск
Список
Период
Сортировка
От Seref Arikan
Тема Is it nonsense (read: stupid) to keep count of child entries via triggers and a custom table?
Дата
Msg-id CA+4ThdovnVVFW3Ou4NZ6XJYJ2rjjW8C-E8OYprUuidVQcm4+0w@mail.gmail.com
обсуждение исходный текст
Ответы Re: Is it nonsense (read: stupid) to keep count of child entries via triggers and a custom table?  (Craig Ringer <ringerc@ringerc.id.au>)
Список pgsql-general
Greetings,
I need to keep various information related to a parent entity (the Electronic Health Record for a single patient) and its children (partitions of the EHR, since it can get very big).
It is important that I know how many partitions exist for an EHR, and I'd like to avoid a query that'll count the partitions (which'll probably go to hundreds of millions) with a parent id as criteria.
Other than count, there is also significant info such as some metadata for the last added partition which must be accessed along with the count.

Can I simply adopt the naive approach of updating an EHR metadata table within a transaction in every partition addition/deletion operation? (update/decrease count, write last added partition's metadata to this table or remove it etc) Any hidden nasty surprises you can see? A better way of doing this?

Best regards
Seref

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

Предыдущее
От: jobs@kaufda.de
Дата:
Сообщение: Postgres DBA in Berlin, Germany
Следующее
От: Merlin Moncure
Дата:
Сообщение: Re: Postgres DBA in Berlin, Germany