Re: index not used for bigint without explicit cast

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: index not used for bigint without explicit cast
Дата
Msg-id CAH2-WzkUxnikXJ_MyYgeZWe=J-+xbMgV+MeyL-XayLgRn1dd4w@mail.gmail.com
обсуждение исходный текст
Ответ на index not used for bigint without explicit cast  ("Sam.Mesh" <Sam.Mesh@gmail.com>)
Ответы Re: index not used for bigint without explicit cast
Список pgsql-bugs
On Tue, Jan 17, 2023 at 5:44 PM Sam.Mesh <Sam.Mesh@gmail.com> wrote:
> The problem arrises with the other case, where the values from the table are to be converted to match the datatype of
thequery (i.e., we give numeric in query and the column is of bigint type). As Postgres can only cast a bigint to
numeric,the only option it has is to convert every row in the table to numeric and then compare. Thus in this case, the
indexwon’t be used. 
> ***
>
> Probably, somebody knows the current state of this limitation?

Not all numeric values can be converted to int8 without loss of
precision. If it was allowed, it would create subtle problems. The
same is not true for (say) int4 and int8, which can be mixed in the
way that you would expect.

Internally, int4 and int8 are part of the same btree operator family,
and so follow certain rules which are described here:

https://www.postgresql.org/docs/current/btree-behavior.html

--
Peter Geoghegan



В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Sam.Mesh"
Дата:
Сообщение: index not used for bigint without explicit cast
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: DROP DATABASE deadlocks with logical replication worker in PG 15.1