Re: Not able to purge partition

Поиск
Список
Период
Сортировка
Искать
От
sud
Тема
Re: Not able to purge partition
Дата
Msg-id
CAD=mzVW5ixtcPOXS1R=e1P0D83zKSP6ic38Y5WK9xn+dnn2trg@mail.gmail.com
Ответ на
Список
Дерево обсуждения
Not able to purge partition veem v <veema0000@gmail.com>
Re: Not able to purge partition Laurenz Albe <laurenz.albe@cybertec.at>
Re: Not able to purge partition gparc@free.fr
Re: Not able to purge partition veem v <veema0000@gmail.com>
Re: Not able to purge partition Laurenz Albe <laurenz.albe@cybertec.at>
Re: Not able to purge partition veem v <veema0000@gmail.com>
Re: Not able to purge partition veem v <veema0000@gmail.com>
Re: Not able to purge partition veem v <veema0000@gmail.com>
Re: Not able to purge partition Laurenz Albe <laurenz.albe@cybertec.at>
Re: Not able to purge partition veem v <veema0000@gmail.com>
Re: Not able to purge partition Laurenz Albe <laurenz.albe@cybertec.at>
Re: Not able to purge partition veem v <veema0000@gmail.com>
Re: Not able to purge partition Laurenz Albe <laurenz.albe@cybertec.at>
Re: Not able to purge partition Lok P <loknath.73@gmail.com>
Re: Not able to purge partition sud <suds1434@gmail.com>
Re: Not able to purge partition Laurenz Albe <laurenz.albe@cybertec.at>
Re: Not able to purge partition veem v <veema0000@gmail.com>

On Thu, Mar 21, 2024 at 6:18 PM Laurenz Albe <laurenz.albe@cybertec.at> wrote:

> [create some partitions, then drop a partition of the referenced table]
>

> SQL Error [P0001]: ERROR: cannot drop table schema1.test_part_drop_parent_p2024_02_01 because other objects depend on it
> CONTEXT: SQL statement "DROP TABLE schema1.test_part_drop_parent_p2024_02_01"

That's normal.  If you create a foreign key constraint to a partitioned table, you
can no longer drop a partition of the referenced table.

What you *can* do is detach the partition and then drop it, but detatching will 
be slow because PostgreSQL has to check for referencing rows.

The best solution is to create the foreign key *not* between the partitioned
tables, but between the individual table partitions.   
 
Interesting, even my thought was that the detach+drop parent partition will only look into the specific child partition but not the whole child table.

However, out of curiosity, does this default foreign key setup i.e. foreign keys between the table (but not between the partitions) also make the data load into the child partitions slower ( as it must be then looking and validating the presence of the keys across all the partitions of the parent table)?
 
В списке pgsql-general по дате отправления
От: Alexander Farber
Дата:
От: sud
Дата:
FAQ