From: Holger Jakobs <holger@jakobs.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: Partitioning on the date part of a timestamp & PK issues
Date: Thu, 15 Jul 2021 22:17:56 +0200
Message-ID: <4C13EFB8-F25D-4361-817B-DA997FB15912@jakobs.com> (raw)
In-Reply-To: <CAOC+FBVxcK2fdNXu30LvWkiLuQ3+qSxke5nPajzjaVayHOeRaw@mail.gmail.com>
References: <CAOC+FBVxcK2fdNXu30LvWkiLuQ3+qSxke5nPajzjaVayHOeRaw@mail.gmail.com>
Am 15. Juli 2021 22:10:01 MESZ schrieb Wells Oliver <wells.oliver@gmail.com>:
>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.
>
>Thanks.
>
>--
>Wells Oliver
>wells.oliver@gmail.com <wellsoliver@gmail.com>
--
Maybe you could sister separate date and time and use date as partition key. The timestamp column could be generated in a view as datecol + timecol.
If new data is entered, it could be separated into the two columns via trigger.
Haven't tried it, bit seems feasible.
Regards,
Holger
--
Holger Jakobs, Bergisch Gladbach
+49 178 9759012
- sent from mobile, therefore short -
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: holger@jakobs.com, pgsql-admin@lists.postgresql.org
Subject: Re: Partitioning on the date part of a timestamp & PK issues
In-Reply-To: <4C13EFB8-F25D-4361-817B-DA997FB15912@jakobs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox