pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gregory Stark <stark@enterprisedb.com>
To: Peter Childs <peterachilds@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: optimize query with a maximum(date) extraction
Date: Wed, 05 Sep 2007 15:23:23 +0100
Message-ID: <87tzq9p4x0.fsf@oxford.xeocode.com> (raw)
In-Reply-To: <a2de01dd0709050543j57de8774s9e9e0a576cc21bd1@mail.gmail.com>
References: <302443.65402.qm@web26209.mail.ukl.yahoo.com>
	<87abs1qrhu.fsf@oxford.xeocode.com>
	<87642pqpue.fsf@oxford.xeocode.com>
	<a2de01dd0709050543j57de8774s9e9e0a576cc21bd1@mail.gmail.com>

"Peter Childs" <peterachilds@gmail.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



view thread (12+ messages)  latest in thread

Message-ID: <87tzq9p4x0.fsf@oxford.xeocode.com>
Permalink:  ../87tzq9p4x0.fsf@oxford.xeocode.com/
Also on:    postgresql.org/message-id/87tzq9p4x0.fsf@oxford.xeocode.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: stark@enterprisedb.com, peterachilds@gmail.com
  Subject: Re: optimize query with a maximum(date) extraction
  In-Reply-To: <87tzq9p4x0.fsf@oxford.xeocode.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox