Re: Massive parallel queue table causes index deterioration, butREINDEX fails with deadlocks.

Поиск
Список
Период
Сортировка
От Corey Huinker
Тема Re: Massive parallel queue table causes index deterioration, butREINDEX fails with deadlocks.
Дата
Msg-id CADkLM=cx5b_gEt9SMoZFiM57xvr_eMbp94QjmXcFhS0o3c-dFg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Massive parallel queue table causes index deterioration, butREINDEX fails with deadlocks.  (Gunther <raj@gusw.net>)
Ответы Re: Massive parallel queue table causes index deterioration, butREINDEX fails with deadlocks.  (Justin Pryzby <pryzby@telsasoft.com>)
Список pgsql-performance

Also, the REINDEX command always fails with a deadlock because there is a row lock and a complete table lock involved.

I consider this ultimately a bug, or at the very least there is room for improvement. And I am on version 11.1.
regards,
-Gunther


REINDEX doesn't work concurrently yet (slated for v12).

I think your solution may be something like this:
1. Create a new table, same columns, partitioned on the pending column.
2. Rename your existing queue table old_queue to the partitioned table as a default partition.
3. Rename new table to queue
4. add old_queue as the default partition of queue
5. add a new partition for pending = true rows, set the fillfactor kind of low, maybe 50, you can always change it.  Now your pending = true rows can be one of two places, but your pending = false rows are all in 
6. add all existing old_queue indexes (except those that are partial indexes on pending) to queue, these will be created on the new (empty) partition, and just matched to the existing indexes on old_queue
7. If pending = true records all ultimately become pending = false, wait for normal attrition to reach a state where all rows in the default partition are pending = false. If that won't happen, you may need to manually migrate some with a DELETE-INSERT
8. At this point, you can transactionally remove old_queue as a partition of queue, and then immediately re-add it to queue as the pending = false partition. There won't need to be a default partition.
9. drop all remaining partial indexes on pending, they're no longer useful.

That's roughly my plan for my own hotspot table when we can upgrade to 11.

 

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

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: Massive parallel queue table causes index deterioration, butREINDEX fails with deadlocks.
Следующее
От: Justin Pryzby
Дата:
Сообщение: Re: Massive parallel queue table causes index deterioration, butREINDEX fails with deadlocks.