Re: sequential scan when using bigint value - Mailing list pgsql-general

From Bill Moran
Subject Re: sequential scan when using bigint value
Date
Msg-id 405B06FF.50603@potentialtech.com
Whole thread Raw
In response to sequential scan when using bigint value  (David Garamond <lists@zara.6.isreserved.com>)
List pgsql-general
David Garamond wrote:
> I have a table of 2mil records. The table consists of two columns, id
> (BYTEA/GUID, PK) and i (INT, UNIQUE INDEX). Could someone explain why,
> when using a bigint value like this:
>
>  select * from partition where i=3000000000;
>
> or
>
>  select * from partition where i in (1,2,3,3000000000);
>
> Postgres immediately switches from index scan to seq scan?

I believe it's in the FAQ.  But Postgres always uses a sequential scan
when types don't match.

If you're going to be looking for BIGINTs in that table, you should
probably set i to BIGINT and always cast your search criterea to
BIGINT.  Otherwise, I can't imagine why you would be looking for a
BIGINT in an INT field.

--
Bill Moran
Potential Technologies
http://www.potentialtech.com


pgsql-general by date:

Previous
From: David Garamond
Date:
Subject: Index selection (and partial index) for BYTEA field
Next
From: Pierre Didelon
Date:
Subject: unsigned types, binary op. and cast pb