Seqscan in MAX(index_column) - Mailing list pgsql-hackers

From Paulo Scardine
Subject Seqscan in MAX(index_column)
Date
Msg-id 008a01c372f1$55f65e40$6301a8c0@Administrador
Whole thread Raw
In response to database corruption  (Joe Conway <mail@joeconway.com>)
Responses Re: Seqscan in MAX(index_column)
List pgsql-hackers
(Perhaps a newbie question, but I tried to google this out without success).

Why postgres does an expensive seqscan to find the max(value) for an indexed
column? I think MAX() does not know or cares if a column is indexed, but...
Should not it? BTW, is there some smarter trick to do that?

I know I can just do a very fast (SELECT pk FROM foo ORDER BY pk DESC LIMIT
1) instead, but my coleagues are arguing that MAX(indexed_column) seems to
be a lot
more smarter in MS-SQLServer and I end up without a good response.

Thank you,
--
Paulo Scardine
Brazil




pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Potential bug in ALTER TABLE?
Next
From: "Shridhar Daithankar"
Date:
Subject: Re: Seqscan in MAX(index_column)