Re: Same condition in the CTE and in the subsequent JOIN using it

From: Andreas Kretschmer <andreas(at)a-kretschmer(dot)de>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Same condition in the CTE and in the subsequent JOIN using it
Date: 2018-04-25 17:36:41
Message-ID: ac694010-61fb-55c0-926d-f663e183e9d2@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Am 25.04.2018 um 17:45 schrieb Alexander Farber:
> Thank you for any hints, I apologize if my question is too specific
> and difficult to answer...

i haven't checked the whole query, but where-conditions from the outer
query are not pushed down into the CTE-query. First the whole CTE will
be materialized, then the outer query executed.
that said, it is better to define the where-condition in the cte.

https://blog.2ndquadrant.com/postgresql-ctes-are-optimization-fences/

Regards, Andreas

--
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Poty 2018-04-25 18:07:30 Issue on public schéma with Pg_restore
Previous Message Alexander Farber 2018-04-25 15:45:39 Same condition in the CTE and in the subsequent JOIN using it