Re: creating a subset DB efficiently ?

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: creating a subset DB efficiently ?
Дата
Msg-id f204d4ac-88b2-40de-ad01-3a30728404ff@aklaver.com
обсуждение исходный текст
Ответ на creating a subset DB efficiently ?  (David Gauthier <dfgpostgres@gmail.com>)
Список pgsql-general
On 3/8/24 08:22, David Gauthier wrote:
> Here's the situation....
> 
> - The DB contains data for several projects.
> - The tables of the DB contain data for all projects (data is not 
> partitioned on project name or anything like that)
> - The "project" identifier (table column) exists in a few "parent" 
> tables with many child... grandchild,... tables under them connected 
> with foreign keys defined with "on delete cascade".  So if a record in 
> one of the parent table records is deleted, all of its underlying, 
> dependent records get deleted too.

How many "... child... grandchild,... tables" ?

Do these tables constitute all the tables in the database?


> Related question...
> The "delete from par_tbl_a where project <> 'a' " is taking forever.  I 
> fear it's because it's trying to journal everything in case I want to 
> rollback.  But this is just in the archive DB and I don't mind taking 
> the risk if I can speed this up outside of a transaction.  How can I run 
> a delete command like this without the rollback recovery overhead ?

I am assuming that at the point you do  "delete from par_tbl_a where 
project <> 'a' " project a is no longer receiving data and its records 
are static. Further assuming there is a PK that you could order by, then 
it would seem the way to go would be to delete in batches as determined 
by the PK.


-- 
Adrian Klaver
adrian.klaver@aklaver.com




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

Предыдущее
От: kuldeep singh
Дата:
Сообщение: Re: Insert with Jsonb column hangs
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Seeing high query planning time on Azure Postgres Single Server version 11.