From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, andrewbille(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #19086: pg_dump --data-only selects and do not uses index definitions for the dumped tables. |
Date: | 2025-10-14 23:56:25 |
Message-ID: | CAApHDvoU2O-_zKNL-toHwkDcMXCzzvgRUTnA3baEEhCB4vqMRw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Wed, 15 Oct 2025 at 11:03, Nathan Bossart <nathandbossart(at)gmail(dot)com> wrote:
> FWIW the getIndexes() query does tend to be one of the slowest, even with
> intact system indexes. I've no concrete proposals, but there might be some
> room for improvement. I don't think we gain all that much by simply
> avoiding the query in probably-somewhat-rare use-cases. IMHO it ought to
> be reworked for efficiency.
The extra slowness comes from all the subqueries in the targetlist, 3
of which are going to pg_attribute using the same join condition. That
results in 3 separate scans of pg_attribute, 2 more than needed.
The query could be made more efficient generally by doing a left join
to pg_attribute instead and then GROUP BY i.indexrelid.
I tried rewriting the query so that pg_attribute is joined to rather
than subqueries. With 1500 tables I get:
master:
ignore_system_indexes = on
Execution Time: 6853.262 ms
ignore_system_indexes = off
Execution Time: 66.781 ms
Rewritten query:
ignore_system_indexes = on
Execution Time: 53.351 ms
ignore_system_indexes = off
Execution Time: 56.965 ms
David
Attachment | Content-Type | Size |
---|---|---|
pg_dump_getIndexes.sql | application/octet-stream | 5.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Bille | 2025-10-15 02:21:05 | Re: BUG #19086: pg_dump --data-only selects and do not uses index definitions for the dumped tables. |
Previous Message | Nathan Bossart | 2025-10-14 22:03:12 | Re: BUG #19086: pg_dump --data-only selects and do not uses index definitions for the dumped tables. |