Re: Postgres - search for value throughout many tables?

From: Christopher Browne <cbbrowne(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: czezz(at)o2(dot)pl, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Postgres - search for value throughout many tables?
Date: 2018-08-08 17:16:40
Message-ID: CAFNqd5WjUMzeNUBoX4HZ54Hg6StumNWuUGatqDzv5qofsYVTnA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 8 Aug 2018 at 10:14, David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> On Wednesday, August 8, 2018, czezz <czezz(at)o2(dot)pl> wrote:
>>
>> Hi everyone,
>> I want to aks if anyone knows is there a way to search for specific "value" throughout list of tables OR all tables in databse?
>
>
> Can you pg_dump your database to plain text and search that? Nothing built in provides that ability though you possibly could work up something using dynamic sql.

If there are some tables that are extraordinarily large that would not
be good candidates, this could be excessively expensive.

If you can identify a specific set of tables that are good candidates,
then a faster option might involve:
pg_dump --data-only --table=this_table --table=that_table
--table=other_table databaseURI

or, if there are only a few tables to omit...
pg_dump --data-only --exclude-table=this_irrelevant_big_table
--exclude-table=another_big_irrelevant_table databaseURI

--
When confronted by a difficult problem, solve it by reducing it to the
question, "How would the Lone Ranger handle this?"

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kyle Samson 2018-08-08 17:23:14 Re: found xmin from before relfrozenxid on pg_catalog.pg_authid
Previous Message Vijay Rajah 2018-08-08 15:21:23 Postgres replication -- .done file in slave