From: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com> |
---|---|
To: | Gunther <raj(at)gusw(dot)net> |
Cc: | postgres performance list <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Massive parallel queue table causes index deterioration, but REINDEX fails with deadlocks. |
Date: | 2019-02-24 21:34:34 |
Message-ID: | CADkLM=cx5b_gEt9SMoZFiM57xvr_eMbp94QjmXcFhS0o3c-dFg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Pryzby | 2019-02-24 22:43:17 | Re: Massive parallel queue table causes index deterioration, but REINDEX fails with deadlocks. |
Previous Message | Peter Geoghegan | 2019-02-24 20:41:39 | Re: Massive parallel queue table causes index deterioration, but REINDEX fails with deadlocks. |