pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dror Matalon <dror@zapatec.com>
To: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: Speeding up Aggregates
Date: Thu, 9 Oct 2003 20:55:26 -0700
Message-ID: <20031010035526.GT2979@rlx11.zapatec.com> (raw)
In-Reply-To: <20031010013522.GB18596@wolff.to>
References: <20031003202120.GO87525@rlx11.zapatec.com>
	<1065217488.91586.3.camel@jester>
	<20031003215347.GQ87525@rlx11.zapatec.com>
	<1065219028.91586.8.camel@jester>
	<87llrvbx0f.fsf@stark.dyndns.tv>
	<20031008181819.GJ2979@rlx11.zapatec.com>
	<87ekxm9fjf.fsf@stark.dyndns.tv>
	<20031010004446.GN2979@rlx11.zapatec.com>
	<20031010013522.GB18596@wolff.to>

On Thu, Oct 09, 2003 at 08:35:22PM -0500, Bruno Wolff III wrote:
> On Thu, Oct 09, 2003 at 17:44:46 -0700,
>   Dror Matalon <dror@zapatec.com> wrote:
> > 
> > How is doing order by limit 1 faster than doing max()? Seems like the
> > optimizer will need to sort or scan the data set either way. That part
> > didn't actually make a difference in my specific case.
> 
> max() will never be evaluated by using an index to find the greatest value.
> So in many cases using order by and limit 1 is faster.

Ouch. I just double checked and you're right. Is this considered a bug,
or just an implementation issue? 

While I've seen this hint a few times in the lists, it seems like it's
one of those magic incantations that those in the know, know about, and
that people new to postgres are going to be surprised by the need to use
this idiom.

Regards,

Dror

-- 
Dror Matalon
Zapatec Inc 
1700 MLK Way
Berkeley, CA 94709
http://www.zapatec.com



view thread (22+ messages)  latest in thread

Message-ID: <20031010035526.GT2979@rlx11.zapatec.com>
Permalink:  ../20031010035526.GT2979@rlx11.zapatec.com/
Also on:    postgresql.org/message-id/20031010035526.GT2979@rlx11.zapatec.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: dror@zapatec.com
  Subject: Re: Speeding up Aggregates
  In-Reply-To: <20031010035526.GT2979@rlx11.zapatec.com>
  References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> <87llrvbx0f.fsf@stark.dyndns.tv> <20031008181819.GJ2979@rlx11.zapatec.com> <87ekxm9fjf.fsf@stark.dyndns.tv> <20031010004446.GN2979@rlx11.zapatec.com> <20031010013522.GB18596@wolff.to> <20031010035526.GT2979@rlx11.zapatec.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