Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1shWQh-003KA8-Gk for pgsql-admin@arkaria.postgresql.org; Fri, 23 Aug 2024 15:42:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1shWQd-00EY3D-Tu for pgsql-admin@arkaria.postgresql.org; Fri, 23 Aug 2024 15:42:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <010001917fe71552-589dbc9b-2c78-4a0d-8405-040db3cc09d7-000000@amazonses.com>) id 1shWQd-00EY2x-Fc for pgsql-admin@lists.postgresql.org; Fri, 23 Aug 2024 15:42:20 +0000 Received: from a48-116.smtp-out.amazonses.com ([54.240.48.116]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from <010001917fe71552-589dbc9b-2c78-4a0d-8405-040db3cc09d7-000000@amazonses.com>) id 1shWQb-0015A1-Ge for pgsql-admin@lists.postgresql.org; Fri, 23 Aug 2024 15:42:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1724427736; h=Content-Type:Content-Transfer-Encoding:From:Mime-Version:Subject:Date:Message-Id:References:In-Reply-To:To:Feedback-ID; bh=UHVhTOspUVXrenLBwnn9hCjEkcJ9ys0WLdbPB3D059g=; b=G/3sWkiKU5MOiZqDDSDWaM++q/K8Tb7TIOnc49Zixu0Tv2PQTJFMcCl0S4WmDS4a aWHg17gD/z4FiYDSLtTORV6mHF53ZEv+Gpwhv5M3mqAoy6uAGOXkfeSAYXy4uCs9bBY kNBe89GaV8dcRZvUwtCB01eE7CoNxFd/loZh0tQA= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Doug Reynolds Mime-Version: 1.0 (1.0) Subject: Re: checking for a NULL date in a partitioned table kills performance Date: Fri, 23 Aug 2024 15:42:16 +0000 Message-ID: <010001917fe71552-589dbc9b-2c78-4a0d-8405-040db3cc09d7-000000@email.amazonses.com> References: <1F2BA008-3732-4289-876A-EF6889474E08@elevated-dev.com> In-Reply-To: <1F2BA008-3732-4289-876A-EF6889474E08@elevated-dev.com> To: Pgsql-admin X-Virus-Scanned: clamav-milter 0.103.9 at postfix X-Virus-Status: Clean X-Mailer: iPhone Mail (21G93) Feedback-ID: ::1.us-east-1.L+CISTGIImABHDx8bBKKEgULZ36xzLwmtjped/xJNPU=:AmazonSES X-SES-Outgoing: 2024.08.23-54.240.48.116 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The only difference is that you would be reading from one index instead of t= wo, which could be more efficient.=20 Sent from my iPhone > On Aug 23, 2024, at 11:19=E2=80=AFAM, Scott Ribe wrote: >=20 > =EF=BB=BF >>=20 >> On Aug 23, 2024, at 5:39=E2=80=AFAM, Doug Reynolds wr= ote: >>=20 >> You could try something really ugly where you make a function index that C= OALESCEs the nulls to 1-1-1900 and use the COALESCE in the query. >=20 > 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 in= dex would help. No matter what, it seems that sequential scans of all partit= ions will be required since most rows have it null, and it's not even relate= d to the partition key. >=20