Re: aggregate on zero rows slow? - Mailing list pgsql-general

From Shaun Thomas
Subject Re: aggregate on zero rows slow?
Date
Msg-id Pine.LNX.4.44.0205021007510.16874-100000@hamster.lee.net
Whole thread Raw
In response to Re: aggregate on zero rows slow?  (Patrick Welche <prlw1@newn.cam.ac.uk>)
List 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@newn.cam.ac.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@townnews.com    AIM  : trifthen                      |
| Web  : www.townnews.com                                             |
|                                                                     |
|     "Most of our lives are about proving something, either to       |
|      ourselves or to someone else."                                 |
|                                           -- Anonymous              |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+



pgsql-general by date:

Previous
From: Ben-Nes Michael
Date:
Subject: Re: Joe Celko Function
Next
From: Bruno Wolff III
Date:
Subject: Re: is there a way