Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iiUzh-0007yY-0H for pgsql-admin@arkaria.postgresql.org; Sat, 21 Dec 2019 02:59:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iiUzf-0001vz-JB for pgsql-admin@arkaria.postgresql.org; Sat, 21 Dec 2019 02:59:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iiUzf-0001vs-9I for pgsql-admin@lists.postgresql.org; Sat, 21 Dec 2019 02:59:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iiUzd-0007I1-3d for pgsql-admin@postgresql.org; Sat, 21 Dec 2019 02:59:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id xBL2xkWj009227; Fri, 20 Dec 2019 21:59:46 -0500 From: Tom Lane To: Wells Oliver cc: pgsql-admin Subject: Re: Partitioning by month causing an error? In-reply-to: References: Comments: In-reply-to Wells Oliver message dated "Fri, 20 Dec 2019 16:49:12 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9225.1576897186.1@sss.pgh.pa.us> Date: Fri, 20 Dec 2019 21:59:46 -0500 Message-ID: <9226.1576897186@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Wells Oliver writes: > I have a partition per each month, like this: > CREATE TABLE mmd_yr2019_3 PARTITION OF mmd FOR VALUES FROM ('2019-03-01') > TO ('2019-03-31'); > CREATE TABLE mmd_yr2019_4 PARTITION OF mmd FOR VALUES FROM ('2019-04-01') > TO ('2019-04-30'); > This breaks for dates at the end of the month. What's the better way to > write the bounds? 3/1 to 4/1 and then 4/1 to 5/1? Does that cause some > overlap issue? The rule is that a range partition from A to B covers values A <= X < B. So you should be using first-of-the-month dates for all of these values. As you have it, there's gaps in the allowable values, totally aside from the PITA factor of having to identify the last day of each month accurately. regards, tom lane