Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: optimize query with a maximum(date) extraction



"Peter Childs" <peterachilds(at)gmail(dot)com> writes:

> My personal reaction is why are you using distinct at all?
>
> why not
>
> select id,
>        min(the_date) as min_date,
>        max(the_date) as max_date
>   from my_table group by id;
>
> Since 8.0 or was it earlier this will use an index should a reasonable one
> exist.

That's not true for this query. In fact that was precisely the original query
he as looking to optimize.


-- 
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group