From: | Tobias Brox <tobias(at)nordicbet(dot)com> |
---|---|
To: | Tobias Brox <tobias(at)nordicbet(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: max/min and index usage |
Date: | 2006-12-06 03:17:13 |
Message-ID: | 20061206031713.GA26712@oppetid.no |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
[Tobias Brox - Wed at 04:01:56AM +0100]
> We're using 8.1 - I thought such a construct was safe in pg 8.1:
>
> select max(indexed_value) from huge_table;
>
> while earlier we had to use:
>
> select indexed_value from huge_table order by indexed_value desc limit 1;
>
> seems like I was wrong:
The difference is all about those NULL values ... those columns are quite
sparsely populated in the table. The second query gives NULL, which is
not much useful :-)
However, I made a partial index to solve this problem - this query is
able to use the partial index:
select indexed_value from huge_table where indexed_value is not NULL
order by indexed_value desc limit 1;
while this one is not:
select max(indexed_value) from huge_table;
I guess this is a bug? :-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-12-06 03:29:53 | Re: max/min and index usage |
Previous Message | Tobias Brox | 2006-12-06 03:01:56 | max/min and index usage |