Re: Why does a simple query not use an obvious index? - Mailing list pgsql-performance

From Greg Stark
Subject Re: Why does a simple query not use an obvious index?
Date
Msg-id 87fz65k5sq.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: Why does a simple query not use an obvious index?  ("Scott Marlowe" <smarlowe@qwest.net>)
Responses Re: Why does a simple query not use an obvious index?
Re: Why does a simple query not use an obvious index?
Re: Why does a simple query not use an obvious index?
List pgsql-performance
"Scott Marlowe" <smarlowe@qwest.net> writes:

> Also, count(*) is likely to always generate a seq scan due to the way
> aggregates are implemented currently in pgsql.  you might want to try:

Huh? I'm curious to know what you're talking about here.

> select somefield from sometable where timestampfield > now()-'60
> seconds'::interval
>
> and count the number of returned rows.  If there's a lot, it won't be
> any faster, if there's a few, it should be a win.

Why would this ever be faster? And how could postgres ever calculate that
without doing a sequential scan when count(*) would force it to do a
sequential scan?

--
greg

pgsql-performance by date:

Previous
From: Greg Stark
Date:
Subject: Re: Why does a simple query not use an obvious index?
Next
From: "Scott Marlowe"
Date:
Subject: Re: Why does a simple query not use an obvious index?