In pg_dump, avoid doing per-table queries for RLS policies.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 31 Aug 2021 19:04:05 +0000 (15:04 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 31 Aug 2021 19:04:05 +0000 (15:04 -0400)
commita20a9f26cefcf4e35ba7bb3d9e8672cb4ce1cf32
tree748810485910716fd49b32650373e7d28c9db5f3
parent9407dbbcb5b587cbefc4af14d1612b49abcb143b
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.GA26282@depesz.com
src/bin/pg_dump/pg_dump.c