Re: CTE Materialization

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Дмитрий Иванов <firstdismay(at)gmail(dot)com>
Cc: Paul van der Linden <paul(dot)doskabouter(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: CTE Materialization
Date: 2021-12-08 02:14:37
Message-ID: CAKFQuwYcrM3dLR8N1wy6qdSnmzaPvpY_M1YGdCJG64J75bXRcg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Dec 7, 2021 at 6:40 PM Дмитрий Иванов <firstdismay(at)gmail(dot)com> wrote:

> I beg your pardon.
> The problem is more or less clear to me, but the solution is not. What
> does the "hack is to add an "offset 0" to the query" suggest? Thank you.
>
>
A subquery with a LIMIT clause cannot have where clause expressions in
upper parts of the query tree pushed down it without changing the overall
query result - something the planner is not allowed to do. For the hack,
since adding an actual LIMIT clause doesn't make sense you omit it, but
still add the related OFFSET clause so the planner still treats the
subquery as a LIMIT subquery. And since you don't want to skip any rows
you specify 0 for the offset.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2021-12-08 03:41:38 Re: Working with fixed-point calculations in C
Previous Message Дмитрий Иванов 2021-12-08 01:39:52 Re: CTE Materialization