Re: sequential scan when using bigint value

Поиск
Список
Период
Сортировка
От Bill Moran
Тема Re: sequential scan when using bigint value
Дата
Msg-id 405B06FF.50603@potentialtech.com
обсуждение исходный текст
Ответ на sequential scan when using bigint value  (David Garamond <lists@zara.6.isreserved.com>)
Список 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 по дате отправления:

Предыдущее
От: David Garamond
Дата:
Сообщение: Index selection (and partial index) for BYTEA field
Следующее
От: Pierre Didelon
Дата:
Сообщение: unsigned types, binary op. and cast pb