Re: Planner regression in 9.1: min(x) cannot use partial index with NOT NULL - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Planner regression in 9.1: min(x) cannot use partial index with NOT NULL
Date
Msg-id 2379.1300771820@sss.pgh.pa.us
Whole thread Raw
In response to Re: Planner regression in 9.1: min(x) cannot use partial index with NOT NULL  (Greg Stark <gsstark@mit.edu>)
List pgsql-hackers
Greg Stark <gsstark@mit.edu> writes:
> On Tue, Mar 22, 2011 at 4:35 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Reimplement planner's handling of MIN/MAX aggregate optimization (again).

> I'm just curious, Why is this no longer an interesting special case?

> --- this is an interesting special case as of 9.1
> -explain (costs off)
> -  select min(unique2) from tenk1 where unique2 = 42;
> -                  QUERY PLAN
> ------------------------------------------------
> - Aggregate
> -   ->  Index Scan using tenk1_unique2 on tenk1
> -         Index Cond: (unique2 = 42)

In the pathkey-based implementation, that resulted in an empty pathkey
list, which that implementation couldn't deal with.  I figured that was
okay because the default plan isn't bad in such a case, but I put in a
test case (probably because the code failed before I put in a defense
against it, but I don't recall for sure).  It's not particularly a
corner case for the new code, though, and the resulting plan changed
(because the new code will in fact turn this into a LIMIT subselect
anyway).  So I debated whether to change the expected output or just
take it out, and I chose the latter.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Planner regression in 9.1: min(x) cannot use partial index with NOT NULL
Next
From: Heikki Linnakangas
Date:
Subject: Re: How to look at the Expression Trees