Re: pgsql: Fix O(N^2) performance issue in pg_publication_tables view.

From: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Fix O(N^2) performance issue in pg_publication_tables view.
Date: 2019-05-22 19:54:54
Message-ID: CAFcNs+r0sKuodMySqypN_Lt=dsF8aOiVUnTWQ2bY1vLU6RZExQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Wed, May 22, 2019 at 3:01 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> =?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= <fabriziomello(at)gmail(dot)com> writes:
> > Just one doubt, why use LATERAL with pg_get_publication_tables SRF
instead
> > of JOIN direct to pg_publication_rel?
>
> Yes, LATERAL is just a noise word in this context, but I think
> it's good for documentation purposes.
>
> If you're asking why I used a comma instead of JOIN ... ON TRUE,
> it's because I don't find the latter to be particularly readable
> or good style. YMMV.
>
> (I agree it's a little weird that the original coding had a mix
> of comma and JOIN syntax, but I did not feel a need to revisit
> that.)
>

I'm not wonder about mix of comma and JOIN syntax, I meant why don't do it?

- FROM pg_publication P,
- LATERAL pg_get_publication_tables(P.pubname) GPT,
- pg_class C JOIN pg_namespace N ON (N.oid = C.relnamespace)
- WHERE C.oid = GPT.relid;
+ FROM pg_publication P
+ JOIN pg_publication_rel PR ON (PR.prpubid = P.oid)
+ JOIN pg_class C ON (C.oid = PR.prrelid)
+ JOIN pg_namespace N ON (N.oid = C.relnamespace);

There are some case I missed to force us to use pg_get_publication_tables
SRF instead of use pg_publication_rel ??

Regards,

--
Fabrízio de Royes Mello Timbira - http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2019-05-22 19:57:47 Re: pgsql: Fix O(N^2) performance issue in pg_publication_tables view.
Previous Message Tom Lane 2019-05-22 18:01:38 Re: pgsql: Fix O(N^2) performance issue in pg_publication_tables view.