Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m49V3-0000KV-Hn for pgsql-admin@arkaria.postgresql.org; Thu, 15 Jul 2021 22:06:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m49V2-00058O-9u for pgsql-admin@arkaria.postgresql.org; Thu, 15 Jul 2021 22:06:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m49V1-00058F-Vi for pgsql-admin@lists.postgresql.org; Thu, 15 Jul 2021 22:06:32 +0000 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m49Uz-0003yQ-Ji for pgsql-admin@lists.postgresql.org; Thu, 15 Jul 2021 22:06:30 +0000 Received: by mail-oi1-x22f.google.com with SMTP id w194so8506581oie.5 for ; Thu, 15 Jul 2021 15:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=AgxtYhFMcm7sqZ4VksR3241fUkq6hnrzN0euQGeXU1U=; b=Pdqg4aUT+rtD2uwSU4yTmi55VEsDhxon4eulboFBHjxPPAXUMCzBrpHTKSGrCbq1xS 6xw1R9vYJkWhzSyCd/hvW5jV4epnIxbFMV3xUOK2vF41tAQZDtpFtzRQjGEA8o9FGJM0 Sk37ZHpXuI2s5ZZHOYsgExIs4bdFvqpJnoj+d4Uz0W5DGyLqSIevr//wXsTjmF0IssRA SiigXHkFX0t+NRziYejeNmc3xjKK27tz5hj39JFTkJQ/8c2cz1Dp2gxkq+vftkDcHKAn 1B7SmiW5YDsV1PlYhdGcihc+KhFKmGi6xEKv6Voh4Tx7ClLYnNtNy/Be9T+/WcZEsHKK 6ZGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=AgxtYhFMcm7sqZ4VksR3241fUkq6hnrzN0euQGeXU1U=; b=XJ8AvgoxzyxOk2GkcTARc9B8pBAjb8EPYU2Y2UbvZz9OzRwbaYIRLBasiNhRaxIPU1 lB7bSN+grbpcJce0gRQYEO+5Vwriz6gbuBGdp/wBQbT9t+uYWdRXIhrzzbkEjCdmpnmp YA/EfScQX5qyR7bdh1kgibhZ4Eiaqz7Quz6t+QgiqXK2PfNTqnRT/1lGAWfkMKmrJlsY l9IpQGJtvehTV4FeVsRlKtJTMAjZaqhK3e+Lu9kzEM1andudKWaucoXjgu3FMGa8VpGl 16AE+WqQ4AsgiIBDLqJBVZMzkFTibuseJ1W15cffUnU5A9EYQXT5g7R5U7tBZcjZ1Fr8 PU4Q== X-Gm-Message-State: AOAM531ejzZTsekWsP3/PWwHrETun4d6GlPgcIXvhGWiEkKQgDQvfZZb 0We50mI6KmW0Qsi6G+FZ8moJXca1EKQ= X-Google-Smtp-Source: ABdhPJxUVF3yUg3xdD+Xang+fwyg6cDBBuIE6sezxMkIaQOwnSJCgWBhVqLF+uwXqrt+kmWyaFx/BA== X-Received: by 2002:a05:6808:10d0:: with SMTP id s16mr9758682ois.79.1626386788466; Thu, 15 Jul 2021 15:06:28 -0700 (PDT) Received: from [192.168.88.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id a137sm911477oib.0.2021.07.15.15.06.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jul 2021 15:06:27 -0700 (PDT) Subject: Re: Partitioning on the date part of a timestamp & PK issues To: pgsql-admin@lists.postgresql.org References: From: Ron Message-ID: <13f09d24-a255-ac33-7745-6a2f59d49679@gmail.com> Date: Thu, 15 Jul 2021 17:06:26 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/15/21 3:10 PM, Wells Oliver wrote: > I have a table like so: > > CREATE TABLE t ( >     guid uuid not null, >     seq smallint not null, >     tid smallint not null, >     ts timestamp without time zone not null, >     x real, >     y real, >     z real, >     primary key (guid, tid, seq) > ) partition by range (extract(date from ts)); > > Which results in the error: > > ERROR:  unsupported PRIMARY KEY constraint with partition key definition > DETAIL:  PRIMARY KEY constraints cannot be used when partition keys > include expressions. > > Is there a suitable way to get around this? I can make an additional date > col in the table to use for the partition range, but given the amount of > data we will have, I am trying to be cognizant of storage concerns. > > The PK is the PK, so I'm not sure what options I have there. Why do you feel the need to "extract(date from ts)" instead of just partitioning by "ts"? -- Angular momentum makes the world go 'round.