Re: Progress report of CREATE INDEX for nested partitioned tables
От | Justin Pryzby |
---|---|
Тема | Re: Progress report of CREATE INDEX for nested partitioned tables |
Дата | |
Msg-id | 20221211063334.GB27893@telsasoft.com обсуждение исходный текст |
Ответ на | Progress report of CREATE INDEX for nested partitioned tables (Ilya Gladyshev <ilya.v.gladyshev@gmail.com>) |
Ответы |
Re: Progress report of CREATE INDEX for nested partitioned tables
|
Список | pgsql-hackers |
On Sat, Dec 10, 2022 at 12:18:32PM +0400, Ilya Gladyshev wrote: > Hi, > > I have noticed that progress reporting for CREATE INDEX of partitioned > tables seems to be working poorly for nested partitioned tables. In > particular, it overwrites total and done partitions count when it > recurses down to child partitioned tables and it only reports top-level > partitions. So it's not hard to see something like this during CREATE > INDEX now: > > postgres=# select partitions_total, partitions_done from > pg_stat_progress_create_index ; > partitions_total | partitions_done > ------------------+----------------- > 1 | 2 > (1 row) Yeah. I didn't verify, but it looks like this is a bug going to back to v12. As you said, when called recursively, DefineIndex() clobbers the number of completed partitions. Maybe DefineIndex() could flatten the list of partitions. But I don't think that can work easily with iteration rather than recursion. Could you check what I've written as a counter-proposal ? As long as we're changing partitions_done to include nested sub-partitions, it seems to me like we should exclude intermediate "catalog-only" partitioned indexes, and count only physical leaf partitions. Should it alo exclude any children with matching indexes, which will also be catalog-only changes? Probably not. The docs say: |When creating an index on a partitioned table, this column is set to the |total number of partitions on which the index is to be created. This |field is 0 during a REINDEX. > I changed current behaviour to report the total number of partitions in > the inheritance tree and fixed recursion in the attached patch. I used > a static variable to keep the counter to avoid ABI breakage of > DefineIndex, so that we could backpatch this to previous versions. I wrote a bunch of assertions for this, which seems to have uncovered an similar issue with COPY progress reporting, dating to 8a4f618e7. I'm not sure the assertions are okay. I imagine they may break other extensions, as with file_fdw. -- Justin
Вложения
В списке pgsql-hackers по дате отправления: