Re: Wrapping a where clause to preserve rows with nulls - Mailing list pgsql-general

From David G. Johnston
Subject Re: Wrapping a where clause to preserve rows with nulls
Date
Msg-id CAKFQuwa2jcBnsZxHmNn7_1MjcmOZx_fU93epBx9+orw3yMNgKw@mail.gmail.com
Whole thread Raw
In response to Wrapping a where clause to preserve rows with nulls  (Adrian Garcia Badaracco <adrian@adriangb.com>)
Responses Re: Wrapping a where clause to preserve rows with nulls
List pgsql-general
On Wednesday, December 18, 2024, Adrian Garcia Badaracco <adrian@adriangb.com> wrote:

Is there any way to include the rows where the predicate evaluates to null while still using an index?

That seems quite unlikely.  Your definition of equality is incompatible with the system’s standard definition while requiring that the standard equals operator be used in the query.  Null values and non-null values are not considered equal, or, put another way, always considered distinct from each other.  A btree index, which handles =, can’t be told to behave differently and so cannot fulfill your desire to produce rows where the stored value is null; it can only produce those equal to 5000.

David J.

pgsql-general by date:

Previous
From: Adrian Garcia Badaracco
Date:
Subject: Re: Wrapping a where clause to preserve rows with nulls
Next
From: Tom Lane
Date:
Subject: Re: Wrapping a where clause to preserve rows with nulls