Re: optimize query with a maximum(date) extraction

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Peter Childs" <peterachilds(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: optimize query with a maximum(date) extraction
Date: 2007-09-05 12:48:18
Message-ID: 162867790709050548l3e1fd155g40b745f2ae42834e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

>
> 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.

without any limits, seq scan is optimal.

Regards
Pavel Stehule

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message JS Ubei 2007-09-05 13:11:31 Re : optimize query with a maximum(date) extraction
Previous Message Peter Childs 2007-09-05 12:43:24 Re: optimize query with a maximum(date) extraction