Re: checking for a NULL date in a partitioned table kills performance

From: shammat(at)gmx(dot)net
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: checking for a NULL date in a partitioned table kills performance
Date: 2024-08-23 06:45:44
Message-ID: 10668bf5-55a7-4c4a-ade4-c1d93c08eeff@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-performance

Sbob schrieb am 22.08.2024 um 23:44:
>
> I am selecting a number of columns and specifying this where clause:
>
> WHERE (
>                     (contract_date IS NULL)
>                     OR
>                     (contract_date > '2022-01-01'::date)
>              )
>

It's not the check for NULL, it's the OR that makes this perform so badly.

I typically never set columns used for range queries to NULL.

Would using infinity instead of NULL be a viable option here?

Then you can remove the OR condition entirely.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Rui DeSousa 2024-08-23 09:54:51 Re: checking for a NULL date in a partitioned table kills performance
Previous Message Muhammad Usman Khan 2024-08-23 04:40:28 Re: checking for a NULL date in a partitioned table kills performance

Browse pgsql-performance by date

  From Date Subject
Next Message Rui DeSousa 2024-08-23 09:54:51 Re: checking for a NULL date in a partitioned table kills performance
Previous Message Muhammad Usman Khan 2024-08-23 04:40:28 Re: checking for a NULL date in a partitioned table kills performance