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

From: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
To: Pgsql-admin <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 15:17:19
Message-ID: 1F2BA008-3732-4289-876A-EF6889474E08@elevated-dev.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-performance

> On Aug 23, 2024, at 5:39 AM, Doug Reynolds <mav(at)wastegate(dot)net> wrote:
>
> You could try something really ugly where you make a function index that COALESCEs the nulls to 1-1-1900 and use the COALESCE in the query.

I don't see how that could be better than just creating a partial index on it WHERE contract_date IS NULL--and anyway I'm sure you're right that no index would help. No matter what, it seems that sequential scans of all partitions will be required since most rows have it null, and it's not even related to the partition key.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Doug Reynolds 2024-08-23 15:42:16 Re: checking for a NULL date in a partitioned table kills performance
Previous Message Sbob 2024-08-23 13:47:00 Re: checking for a NULL date in a partitioned table kills performance

Browse pgsql-performance by date

  From Date Subject
Next Message Doug Reynolds 2024-08-23 15:42:16 Re: checking for a NULL date in a partitioned table kills performance
Previous Message Sbob 2024-08-23 13:47:00 Re: checking for a NULL date in a partitioned table kills performance