Re: retriving views name - Mailing list pgsql-general

From Tom Lane
Subject Re: retriving views name
Date
Msg-id 20557.1002997181@sss.pgh.pa.us
Whole thread Raw
In response to retriving views name  (Emmanuel SARACCO <esaracco@noos.fr>)
List pgsql-general
Emmanuel SARACCO <esaracco@noos.fr> writes:
> I must retrieve views names in a very short time. what can I use.
> for the moment, I use:

> SELECT c.relname FROM pg_class c, pg_rewrite r WHERE (((c.relname !~
> '^pg_'::text) AND (r.ev_class = c.oid)) AND (r.ev_type = '1'::"char"));

If you're using a reasonably recent PG release, there's no need to join
against pg_rewrite.  Just look for pg_class entries with relkind = 'v'.

> is there a more performant way to do this? (I have more than 50.000
> views in my database (those views are generated on the fly to optimize a
> search engine and keep results in memory)). I am running a sort of
> "garbage collector" via cron/psql -c every minutes to destroy views
> older than 10 minutes and I must do this very rapidly!

One must wonder why you create views at all, if you don't intend them
to stick around for long.  Why not just write out the SELECTs in full?
(If you think there's some performance benefit to using a view, you are
quite mistaken.)

            regards, tom lane

pgsql-general by date:

Previous
From: "Gurunandan R. Bhat"
Date:
Subject: Re: Any Good Way To Do Sync DB's?
Next
From: Keary Suska
Date:
Subject: 7.1.3 Install: createlang broken/no pg_shadow