Re: Speeding up query pulling comments from pg_catalog

From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: Speeding up query pulling comments from pg_catalog
Date: 2019-07-20 19:08:00
Message-ID: CAD3a31U5Kb48p32AbiaZqMa-Rg1R3f7JvZY1Vgkx4Y31XqigRg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Sat, Jul 20, 2019 at 7:46 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> But if you do so manually you'll end up with something like
>
> SELECT c.relname AS table, a.attname AS column, d.description AS comment
> FROM
> pg_catalog.pg_attribute a JOIN pg_catalog.pg_class c ON a.attrelid =
> c.oid
> LEFT JOIN pg_catalog.pg_description d ON d.classoid = c.tableoid and
> d.objoid = c.oid and d.objsubid = a.attnum
> WHERE d.description IS NOT NULL;
>
> For me, that formulation is quite a bit faster than the original ---
>

A lot faster for me too (~30-40 ms). Thanks!

and then to add insult to injury, has to search pg_description a second
> time for each hit.
>

Not sure if I'm understanding this correctly, but are you saying that
because col_description() is specified in two places in the query, that it
actually will get called twice? I was under the impression that a function
(at least a non-volatile one) specified multiple times, but with the same
arguments, would only get called once. Is that just wishful thinking?

Cheers,

Ken

--
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ <http://agency-software.org/>*
*https://demo.agency-software.org/client
<https://demo.agency-software.org/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801

Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2019-07-20 19:25:03 Re: Speeding up query pulling comments from pg_catalog
Previous Message Tom Lane 2019-07-20 14:46:44 Re: Speeding up query pulling comments from pg_catalog