Re: Avoid computing ORDER BY junk columns unnecessarily

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Andrew Kane <andrew(at)ankane(dot)org>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Xiaoran Wang <fanfuxiaoran(at)gmail(dot)com>
Subject: Re: Avoid computing ORDER BY junk columns unnecessarily
Date: 2023-12-26 03:18:16
Message-ID: CAMbWs49_r8dKUyjyNUw2KRX8hTxEWz0d8X=gjd=ezyUwoFtCng@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 22, 2023 at 2:38 AM Heikki Linnakangas <hlinnaka(at)iki(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Anton A. Melnikov 2023-12-26 04:38:58 Re: Some performance degradation in REL_16 vs REL_15
Previous Message Amit Kapila 2023-12-26 03:14:44 Re: Track in pg_replication_slots the reason why slots conflict?