Re: Can we get rid of repeated queries from pg_dump?
Laurenz Albe <laurenz.albe@cybertec.at>
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: depesz@depesz.com, Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Date: 2021-08-27T07:33:51Z
Lists: pgsql-hackers, pgsql-general
On Thu, 2021-08-26 at 18:06 +0200, hubert depesz lubaczewski wrote:
> Now for query stats.
>
> To dump it all, pg_dump needed 9173 queries (logged by
> log_min_duration_statement = 0 for this user).
>
> I extracted all queries to separate files, and made stats. In total there were
> only 4257 unique queries.
>
> Then I checked for repeated queries. Top 10 most repeated offenders were:
>
> 615 times : SELECT pg_catalog.format_type('25'::pg_catalog.oid, NULL)
> 599 times : SELECT pg_catalog.format_type('23'::pg_catalog.oid, NULL)
> 579 times : SELECT pg_catalog.format_type('2281'::pg_catalog.oid, NULL)
> 578 times : SELECT pg_catalog.format_type('41946'::pg_catalog.oid, NULL)
> 523 times : SELECT pg_catalog.format_type('701'::pg_catalog.oid, NULL)
> 459 times : SELECT pg_catalog.format_type('42923'::pg_catalog.oid, NULL)
> 258 times : SELECT pg_catalog.format_type('16'::pg_catalog.oid, NULL)
> 176 times : SELECT pg_catalog.format_type('19'::pg_catalog.oid, NULL)
> 110 times : SELECT pg_catalog.format_type('21'::pg_catalog.oid, NULL)
> 106 times : SELECT pg_catalog.format_type('42604'::pg_catalog.oid, NULL)
>
> In total, there were 5000 queries:
> SELECT pg_catalog.format_type('[0-9]+'::pg_catalog.oid, NULL)
>
> But there were only 83 separate oids that were scanned.
That is a strong argument for using a hash table to cache the types.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
Commits
-
In pg_dump, avoid doing per-table queries for RLS policies.
- dd3105286bd8 9.6.24 landed
- db11b4a3db5f 13.5 landed
- bd3611db5a6f 15.0 landed
- ba8f1a0be583 10.19 landed
- a60860ff33fb 11.14 landed
- a20a9f26cefc 14.0 landed
- 6b9667392d81 12.9 landed
-
Cache the results of format_type() queries in pg_dump.
- c4b298ee15aa 11.14 landed
- 0e7bdc722c65 10.19 landed
- 904ce45bfa88 13.5 landed
- 2f1ed9d98c38 12.9 landed
- 9407dbbcb5b5 14.0 landed
- 6c450a861f1a 15.0 landed
- 4645997c8ab7 9.6.24 landed