Re: Massive parallel queue table causes index deterioration, butREINDEX fails with deadlocks.
От | Gunther |
---|---|
Тема | Re: Massive parallel queue table causes index deterioration, butREINDEX fails with deadlocks. |
Дата | |
Msg-id | 00b34d10-67d6-e555-d3ae-35f8c73e194c@gusw.net обсуждение исходный текст |
Ответ на | Re: Massive parallel queue table causes index deterioration, butREINDEX fails with deadlocks. (Jeff Janes <jeff.janes@gmail.com>) |
Ответы |
Re: Massive parallel queue table causes index deterioration, butREINDEX fails with deadlocks.
Re: Massive parallel queue table causes index deterioration, butREINDEX fails with deadlocks. |
Список | pgsql-performance |
Wow, yes, partition instead of index, that is interesting. Thanks Corey and Justin.
The index isn't required at all if all my pending jobs are in a partition of only pending jobs. In that case the plan can just be a sequential scan.
And Jeff James, sorry, I failed to show the LIMIT 1 clause on my dequeue query. That was an omission. My query is actually somewhat more complex and I just translated it down to the essentials but forgot the LIMIT 1 clause.
SELECT seqNo, action FROM QueueWHERE pending AND ... other criteria ...LIMIT 1FOR UPDATE SKIP LOCKED;
And sorry I didn't capture the stats for vacuum verbose. And they would be confusing because there are other things involved.
Anyway, I think the partitioned table is the right and brilliant solution, because an index really isn't required. The actual pending partition will always remain quite small, and being a queue, it doesn't even matter how big it might grow, as long as new rows are inserted at the end and not in the middle of the data file and still there be some way of fast skip over the part of the dead rows at the beginning that have already been processed and moved away.
Good thing is, I don't worry about maintenance window. I have the leisure to simply tear down my design now and make a better design. What's 2 million transactions if I can re-process them at a rate of 80/s? 7 hours max. I am still in development. So, no need to worry about migration / transition acrobatics. So if I take Corey's steps and envision the final result, not worrying about the transition steps, then I understand this:
1. Create the Queue table partitioned on the pending column, this creates the partition with the pending jobs (on which I set the fillfactor kind of low, maybe 50) and the default partition with all the rest. Of course that allows people with a constant transaction volume to also partition on jobId or completionTime and move chunks out to cold archive storage. But that's beside the current point.
-Gunther
В списке pgsql-performance по дате отправления:
Предыдущее
От: Gunther SchadowДата:
Сообщение: 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.