Re: Third thoughts about the DISTINCT MAX() problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Third thoughts about the DISTINCT MAX() problem
Date: 2008-03-29 17:50:10
Message-ID: 10400.1206813010@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Plan B was to try to revert to the way sort clause matching was
> done pre-8.3, that is have make_sort_from_pathkeys check first
> for a matching ressortgroupref tag before it goes looking for equal()
> expressions.

So I tried that, and after a whole bunch of regression test failures
I realize it won't work. ressortgroupref tags are only guaranteed
unique within a given targetlist --- the values applicable in the
final result tlist might mean something else within a plan node further
down in the tree. Since EquivalenceClasses are global to the whole
plan, trying to match them to tlist entries by ressortgroupref isn't
safe.

This actually calls into question the existing fix for making sure
we pick the right tlist entry when dealing with volatile ORDER BY
expressions. I think it's all right because sorting by such expressions
could only occur at top tree level --- we'd never consider such an
expression as a mergejoin key, for instance. But it seems fragile
and something we'll need to keep an eye on.

Anyway, it seems that the only remaining acceptable fix is the one
involving modifying the EquivalenceClasses when planagg.c makes
its substitutions. Unless someone has another idea.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Atkins-Trimnell, Angus Black 2008-03-29 18:05:29 Connection to PostgreSQL Using Certificate: Wrong Permissions on Private Key File
Previous Message Dean Rasheed 2008-03-29 17:14:36 Re: [PATCHES] Auto-explain patch