Re: enable_incremental_sort changes query behavior

From: Jaime Casanova <jaime(dot)casanova(at)2ndquadrant(dot)com>
To: James Coleman <jtc331(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: enable_incremental_sort changes query behavior
Date: 2020-10-01 07:09:03
Message-ID: CAJGNTeN4iqAAjUn1UJJR-Yhat-B7zsKkj50KN-AYzkE5fStXvw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 30 Sep 2020 at 21:21, James Coleman <jtc331(at)gmail(dot)com> wrote:
>
> On Sat, Sep 26, 2020 at 2:49 PM Jaime Casanova
> <jaime(dot)casanova(at)2ndquadrant(dot)com> wrote:
> >
> > Hi,
> >
> > With sqlsmith I found a query that gives this error:
> > ERROR: ORDER/GROUP BY expression not found in targetlist
> >
[...]
> >
> > But if I set enable_incremental_sort to off the query gets executed
> > without problems (attached the explain produced for that case)
>
> Thanks for the report.
>

Hi,

by experiment I reduced the query to this

--- 0 ---
select distinct
subq_0.c1 as c0,
case when (true = pg_catalog.pg_rotate_logfile_old()) then
ref_0.t else ref_0.t
end
as c4
from
public.ref_0,
lateral (select

ref_0.i as c1
from
generate_series(1, 100) as ref_1) as subq_0
--- 0 ---

the only custom table already needed can be created with this commands:

--- 0 ---
create table ref_0 as select repeat('abcde', (random() * 10)::integer)
t, random() * 1000 i from generate_series(1, 500000);
create index on ref_0 (i);
analyze ref_0 ;
--- 0 ---

> Is there by an chance an index on ref_0.radi_text_temp?
>

there is an index involved but not on that field, commands above
create the index in the right column... after that, ANALYZE the table

> And if you set enable_hashagg = off what plan do you get (or error)?
>

same error

--
Jaime Casanova www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2020-10-01 07:41:09 Re: Add information to rm_redo_error_callback()
Previous Message Kasahara Tatsuhito 2020-10-01 07:06:23 Re: Get memory contexts of an arbitrary backend process