[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? :-)