Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fTrVN-0005V9-No for pgsql-general@arkaria.postgresql.org; Fri, 15 Jun 2018 16:23:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fTrVM-000095-B1 for pgsql-general@arkaria.postgresql.org; Fri, 15 Jun 2018 16:23:16 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fTrVK-00008v-JQ for pgsql-general@lists.postgresql.org; Fri, 15 Jun 2018 16:23:16 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fTrVG-0005XV-Rv for pgsql-general@postgresql.org; Fri, 15 Jun 2018 16:23:13 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 57C9721B30; Fri, 15 Jun 2018 12:23:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 15 Jun 2018 12:23:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=Gojqj8iQXwxHN74bgCeFi6ccJLDuC 6xgxeNvdqToTco=; b=ylbGyox7udibFmhFo6VpEAsLqtv1BJt6q088r5rNmaYka socA4VZ3nJPynw4iTSlWG6R1bYk/m/fq/Cf4ZhU/Ex5qbJ8ej7VpFJQAvSsoyrCs JqtgVepaVpAGMXM+MjeImFqrBeqNZOTTzwZVFWtU/UA6aGL5Dkzpk3l7+zVWhXmS mGRXrpz0afiGicVVmbUYexx+u+6xCBSqT2gn26rcDHq2mWblYb9zh39sPILXymaE cKVA8ezGrT5IWUvX22gleYEo55EHx+hBjt5tQtc8+/LkgbO5ABLLfEh/hjeBLpJM PyVlHewp4lJmS8kIuH8wsEWiqlvxlWqVweATPCo+g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=Gojqj8 iQXwxHN74bgCeFi6ccJLDuC6xgxeNvdqToTco=; b=Lir4ZApVW9raXLK8h6wG1Z uU8R9Zhqrl7fWdwA8+w+bItN+5PZq1Rv5yrozSkOMnDRdXSecaGl/wkxN+c0ZBTu GBfwFxg8eN8jItbKFjwx+evROWztK3dQafdgZ9sSSDI2gAXnywvfCbzsn0P/sqWT ikyV0nGnqBt1Iri2/RgzfqEh4jy4oye8hvwJtYMJU1am9HBdRn1a2GKT4wjy2tFO ge7/uJx0UOlRU+kWL+KGT23axPuC+7rKyddWKppvSjeqRCiRJQf1u/kVwtfVLNqX LuMvdqb5MrPOk3U6+2QwbUuhxtJHTzqbNGJ6jLADVuCygGGqlWcqlT/So/HmqS5Q == X-ME-Proxy: X-ME-Sender: Received: from ranger.suse (50-197-80-2-static.hfc.comcastbusiness.net [50.197.80.2]) by mail.messagingengine.com (Postfix) with ESMTPA id AC8E210255; Fri, 15 Jun 2018 12:23:08 -0400 (EDT) Subject: Re: Partitioning with range types To: Jeremy Finzel , Postgres General References: From: Adrian Klaver Message-ID: <5285bc38-df1f-99fc-7fe6-723630572eb4@aklaver.com> Date: Fri, 15 Jun 2018 09:23:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 06/15/2018 08:26 AM, Jeremy Finzel wrote: > Several months ago we had some detailed discussions about whether to use > separate date columns to indicate a date range, or to use the daterange > data type.  We opted for the latter because this type is specifically > designed for this use case - a table that has a range of valid dates for > the data it contains.  It also has some great operators and functions. > > But I recently discovered that daterange is not supported in any way as > a partition key because it depends on an expression.  I was excited A quick test: Postgres 10.4 create table dr_partition(id integer, dr daterange) PARTITION BY LIST(dr); \d dr_partition Table "public.dr_partition" Column | Type | Collation | Nullable | Default --------+-----------+-----------+----------+--------- id | integer | | | dr | daterange | | | Partition key: LIST (dr) create table dr_1 PARTITION OF dr_partition FOR VALUES IN ('[06/01/2018, 06/30/2018]'); \d dr_1 Table "public.dr_1" Column | Type | Collation | Nullable | Default --------+-----------+-----------+----------+--------- id | integer | | | dr | daterange | | | Partition of: dr_partition FOR VALUES IN ('[2018-06-01,2018-07-01)') > about this possibility in pg11 with unique constraints on the parent > table, but now it appears it may have instead been to our advantage if > we had two separate date columns instead, so that we could use UPSERT > transparently for date-ranged tables. > > Is there any possibility of this feature coming for range types, or, if > we really want to partition using daterange, should we look instead at > two separate date columns? > > Thanks, > Jeremy -- Adrian Klaver adrian.klaver@aklaver.com