Re: PoC: pg_dump --filter-data <file> (like Oracle Where Clause on RMAN for specific tables)
Greg Sabino Mullane <htamfids@gmail.com>
From: Greg Sabino Mullane <htamfids@gmail.com>
To: Kirk Wolak <wolakk@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Andrey Borodin <x4mmm@yandex-team.ru>, Nikolay Samokhvalov <nik@postgres.ai>, Pavel Stehule <pavel.stehule@gmail.com>,
Pavlo Golub <Pavlo.Golub@cybertec.at>
Date: 2025-08-15T17:25:02Z
Lists: pgsql-hackers
I've seen this idea pop up over the years, and it's still a good one. Rather than invent new flags, I think a better approach would be to convince pg_dump to dump a view, such that table foo has a view fooslice to limit / filter the output. Then we can simply do: pg_dump -t foo=view:fooslice and under the hood pg_dump would do COPY (SELECT * FROM fooslice) TO ... rather than COPY foo TO ... While we could make the view mapping into a separate filtering file as you suggest, that's more complexity and also a little more dangerous in an action-at-a-distance way, so I'd rather have people be very specific in the mapping on the command line. I could swear I made a POC years ago for something like this, but it's long gone. If I get some time, I'll give it a fresh attempt. Cheers, Greg -- Crunchy Data - https://www.crunchydata.com Enterprise Postgres Software Products & Tech Support