Re: aggregate on zero rows slow?

From: Shaun Thomas <sthomas(at)townnews(dot)com>
To: Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: aggregate on zero rows slow?
Date: 2002-05-02 15:11:31
Message-ID: Pine.LNX.4.44.0205021007510.16874-100000@hamster.lee.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2 May 2002, Patrick Welche wrote:

> On Wed, May 01, 2002 at 10:21:48PM -0400, Tom Lane wrote:
> > Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk> writes:
> > > ... the select appears to take much longer to complete if the WHERE clause
> > > matches zero rows, than if it matches some rows.
> >
> > Doesn't make any sense to me. Are you sure the same plan is being
> > chosen in both cases? If so, could you post a complete example?
>
> Yes, same plan both cases. Thanks for the answer: as it doesn't make any
> sense to anyone, it must mean there is some corruption somewhere as a result
> of Monday morning's powercut => I'll look elsewhere.

Could it possibly be that, since it can't find any rows, it's fully
exhausting the indexes looking for the values it wants? I mean, a match
would presumably be found in the indexes before hitting the end, but a
non-match wouldn't. If the index is big enough, I could see a query
that returned no results taking longer than one which does.

--
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Shaun M. Thomas INN Database Administrator |
| Phone: (309) 743-0812 Fax : (309) 743-0830 |
| Email: sthomas(at)townnews(dot)com AIM : trifthen |
| Web : www.townnews.com |
| |
| "Most of our lives are about proving something, either to |
| ourselves or to someone else." |
| -- Anonymous |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ben-Nes Michael 2002-05-02 15:13:36 Re: Joe Celko Function
Previous Message Shaun Thomas 2002-05-02 15:06:55 Re: What popular, large commercial websites run