Re: sequential scan when using bigint value

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: sequential scan when using bigint value
Date: 2004-03-19 14:43:11
Message-ID: 405B06FF.50603@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pierre Didelon 2004-03-19 14:58:18 unsigned types, binary op. and cast pb
Previous Message David Garamond 2004-03-19 14:26:08 Index selection (and partial index) for BYTEA field