Re: Query plan for "id IS NULL" on PK

Поиск
Список
Период
Сортировка
От Rob Sargent
Тема Re: Query plan for "id IS NULL" on PK
Дата
Msg-id 8e744026-7547-5d4d-b76c-ca152881ccce@gmail.com
обсуждение исходный текст
Ответ на Re: Query plan for "id IS NULL" on PK  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: Query plan for "id IS NULL" on PK  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
Список pgsql-general
On 2/14/23 15:30, David G. Johnston wrote:
On Tue, Feb 14, 2023 at 3:25 PM Rob Sargent <robjsargent@gmail.com> wrote:

When will id be null in a primary key?


The OP seems to be aware of this...

"We cannot change the query being executed. Is there any way we can make the query planner ignore `OR (id IS NULL)` (as that will never be the case for the PK) and use both `id` clauses in the index condition?"

David J.

Yes, agreed.
But if the query is supposed to be generic and re-used in a situation where id could be null, wouldn't the null id records be fetched every time? 


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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Query plan for "id IS NULL" on PK
Следующее
От: "Peter J. Holzer"
Дата:
Сообщение: Re: Query plan for "id IS NULL" on PK