Re: Strange performance problem - Mailing list pgsql-admin

From Tom Lane
Subject Re: Strange performance problem
Date
Msg-id 32211.1548436922@sss.pgh.pa.us
Whole thread Raw
In response to Strange performance problem  (Alessandro Manzoni <manzoni.alessandro4@gmail.com>)
List pgsql-admin
Alessandro Manzoni <manzoni.alessandro4@gmail.com> writes:
> Then I have a complex query that has two complete different 
> performances, in these two cases:

> case a)
> with getfieldone as (select * from tableone where fieldone = 'one')
> select * from getfieldone
> inner join tabletwo on ... [and other joins]

> case b)
> select * from viewone
> inner join tabletwo on ... [and other joins, the same as case a)]

> I expected the same performance, but case a) lasts a few hundreds ms, 
> while case b) lasts more than 12 seconds.

WITH is an optimization fence (at present --- there is discussion
of relaxing that) so it's not exactly surprising that these queries
perform differently.  I am a little surprised though that case a)
is the faster one; usually, preventing the planner from optimizing
the whole query as one problem makes things worse.

Saying more than that would require a lot more detail.

https://wiki.postgresql.org/wiki/Slow_Query_Questions

            regards, tom lane


pgsql-admin by date:

Previous
From: Alessandro Manzoni
Date:
Subject: Strange performance problem
Next
From: Luis Agustín Solís García-Barbón
Date:
Subject: How upgrade version pgadmin 4