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 1semfa-00Bwbn-10 for pgsql-docs@arkaria.postgresql.org; Fri, 16 Aug 2024 02:26:26 +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 1semfY-002byD-Hg for pgsql-docs@arkaria.postgresql.org; Fri, 16 Aug 2024 02:26:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1semfY-002by4-9W for pgsql-docs@lists.postgresql.org; Fri, 16 Aug 2024 02:26:24 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1semfW-0055BP-7R for pgsql-docs@lists.postgresql.org; Fri, 16 Aug 2024 02:26:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 47G2QJ4a661807; Thu, 15 Aug 2024 22:26:19 -0400 From: Tom Lane To: hmoustaid.mships@gmail.com cc: pgsql-docs@lists.postgresql.org Subject: Re: constraint_exclusion not working correctly In-reply-to: <172364933910.395942.11462602571152584372@wrigleys.postgresql.org> References: <172364933910.395942.11462602571152584372@wrigleys.postgresql.org> Comments: In-reply-to PG Doc comments form message dated "Wed, 14 Aug 2024 15:28:59 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <661805.1723775179.1@sss.pgh.pa.us> Date: Thu, 15 Aug 2024 22:26:19 -0400 Message-ID: <661806.1723775179@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Doc comments form writes: > I have noted that, in order for constraint exclusion to work correctly when > partitioning using inheritance, we must use simple comparisons in check > constraints (e.g., =, >=, <=, BETWEEN, etc.). If conditions are combined > using AND or OR, unnecessary partitions may be scanned. > Therefore, the example in this PostgreSQL documentation will not work > properly with constraints like CHECK (logdate >= DATE '2006-02-01' AND > logdate < DATE '2006-03-01'). However, it will work with the BETWEEN > operator. The example in the documentation works perfectly well for me. regards, tom lane