In pg_dump, avoid doing per-table queries for RLS policies.
authorTom Lane <[email protected]>
Tue, 31 Aug 2021 19:04:05 +0000 (15:04 -0400)
committerTom Lane <[email protected]>
Tue, 31 Aug 2021 19:04:05 +0000 (15:04 -0400)
commitdd3105286bd8c0ade31961cb5a585692c73bca6f
treedd83352e951dfb51ace397fe0ff16224b8be20a3
parent4645997c8ab7fd391df6cd2ff2bfebfc8a135242
In pg_dump, avoid doing per-table queries for RLS policies.

For no particularly good reason, getPolicies() queried pg_policy
separately for each table.  We can collect all the policies in
a single query instead, and attach them to the correct TableInfo
objects using findTableByOid() lookups.  On the regression
database, this reduces the number of queries substantially, and
provides a visible savings even when running against a local
server.

Per complaint from Hubert Depesz Lubaczewski.  Since this is such
a simple fix and can have a visible performance benefit, back-patch
to all supported branches.

Discussion: https://postgr.es/m/20210826084430[email protected]
src/bin/pg_dump/pg_dump.c