From: | Mike Christensen <imaudi(at)comcast(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Index question regarding numeric operators |
Date: | 2008-10-01 20:27:21 |
Message-ID: | 9E85DEED-1A93-406B-9FB2-D40F219CE58A@comcast.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks Tom!
I just tried a query for cooktimes over 1 million to test your theory,
as it would almost instantly be able to tell from the index that there
are zero rows matching that condition. Indeed, it hits the index
which is what I would expect, and the total runtime is 0.163ms.
Thanks again,
Mike
On Oct 1, 2008, at 6:21 AM, Tom Lane wrote:
> Mike Christensen <imaudi(at)comcast(dot)net> writes:
>> As you can see the index is not being used and it's doing a seq scan
>> on the table directly. I would think if Postgres is indeed keeping a
>> btree index on the column, meaning the values would be stored in
>> numerical order, the index would be used to find rows that have a
>> value greater than 30. I'm curious as to why this is not the case,
>> or
>> if perhaps I have my index setup incorrectly for this sort of query.
>
> It's not using the index because it thinks that'll be slower, given
> the
> large fraction of the table it'll have to retrieve anyway. Seeing the
> relatively small runtime I think it made the right choice ---
> extrapolating from the first test suggests that doing this with a
> bitmap
> scan would have taken ~ 3 seconds instead of 1.5.
>
> You could experiment with forcing another plan (using enable_seqscan
> and
> related settings) to see if the planner guessed right or not. Bear in
> mind though that timings for successive runs of related queries will
> be
> affected by caching: the later tests will look faster because the data
> they need is already swapped in.
>
> regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Seb | 2008-10-01 21:16:44 | inserting only new rows from csv file |
Previous Message | Filip Rembiałkowski | 2008-10-01 20:19:29 | Re: "object references" and renaming was: Why Does UPDATE Take So Long? |