Re: CLUSTER sort on abbreviated expressions is broken

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
Cc: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: CLUSTER sort on abbreviated expressions is broken
Date: 2022-04-03 23:11:51
Message-ID: CAH2-Wzn22s42h4Lh6v96GsXSKGd=_6b76mjqip_WFCGnBmTJCw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Apr 3, 2022 at 1:22 AM John Naylor <john(dot)naylor(at)enterprisedb(dot)com> wrote:
> I can confirm the problem on v10 as well.

We will need a backpatchable fix, since Thomas' recent fix (commit
cc58eecc5d75a9329a6d49a25a6499aea7ee6fd6) only targeted the master
branch.

If we really needed the performance advantage of abbreviated keys in
this case then it would have taken more than 7 years for this bug to
come to light. The backpatchable fix can be very simple. We can just
copy what tuplesort_set_bound() does with abbreviated keys in
tuplesort_begin_cluster(), to explicitly disable abbreviated keys
up-front for affected tuplesorts. (Just for CLUSTER tuplesorts on an
expression index.)

--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2022-04-03 23:33:28 Re: CLUSTER sort on abbreviated expressions is broken
Previous Message Thomas Munro 2022-04-03 23:01:30 Re: A qsort template