Re: Avoid computing ORDER BY junk columns unnecessarily - Mailing list pgsql-hackers

From Richard Guo
Subject Re: Avoid computing ORDER BY junk columns unnecessarily
Date
Msg-id CAMbWs49_r8dKUyjyNUw2KRX8hTxEWz0d8X=gjd=ezyUwoFtCng@mail.gmail.com
Whole thread Raw
In response to Avoid computing ORDER BY junk columns unnecessarily  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers

On Fri, Dec 22, 2023 at 2:38 AM Heikki Linnakangas <hlinnaka@iki.fi> wrote:
v1-0004-Omit-columns-from-final-tlist-that-were-only-need.patch

The main patch in this series.

This patch filters out the junk columns created for ORDER BY/GROUP BY,
and retains the junk columns created for RowLocks.  I'm afraid this may
have a problem about out-of-order resnos.  For instance,

create table mytable (foo text, bar text);

# explain select foo from mytable order by bar for update of mytable;
server closed the connection unexpectedly

This query triggers another Assert in apply_tlist_labeling:

    Assert(dest_tle->resno == src_tle->resno);

At first there are three TargetEntry items: foo, bar and ctid, with
resnos being 1, 2 and 3.  And then the second item 'bar' is removed,
leaving only two items: foo and ctid, with resnos being 1 and 3.  So now
we have a missing resno, and finally hit the Assert.

Thanks
Richard

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Track in pg_replication_slots the reason why slots conflict?
Next
From: "Anton A. Melnikov"
Date:
Subject: Re: Some performance degradation in REL_16 vs REL_15