pgsql: In pg_dump, avoid doing per-table queries for RLS policies.

Started by Tom Lanealmost 5 years ago1 messagescomitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

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: /messages/by-id/20210826084430.GA26282@depesz.com

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a60860ff33fbd41685943e1c59a199fe95ee96bd

Modified Files
--------------
src/bin/pg_dump/pg_dump.c | 95 +++++++++++++++++++++--------------------------
1 file changed, 43 insertions(+), 52 deletions(-)