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 1sFSMU-002T5p-2y for pgsql-general@arkaria.postgresql.org; Fri, 07 Jun 2024 05:42:02 +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 1sFSLT-008TFE-Pq for pgsql-general@arkaria.postgresql.org; Fri, 07 Jun 2024 05:41:00 +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 1sFSLT-008TF6-D9 for pgsql-general@lists.postgresql.org; Fri, 07 Jun 2024 05:41:00 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sFSLQ-000PNr-59 for pgsql-general@lists.postgresql.org; Fri, 07 Jun 2024 05:40:58 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2eaae2a6dc1so32716191fa.0 for ; Thu, 06 Jun 2024 22:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717738855; x=1718343655; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iuce32N/yR5pZNPpV3osf/DDjXllQYyoW80CW+faFDE=; b=OcgTr0FKXjyUBZzB77Zifhx93IUQGf4gWtZ0135xsMKhVyWN9wsRnjWeB4cVm2VhGI 6Dc4aSS3y0x9ertnxmiwfDqGUmC1f6XtqrLRr9xiMBYp8YSTPe6Ucx5GhxmxpO8qofT+ F/9yfJWuVU7p0zb5ueTn8n/vNQeoUYFPV5n/1Ekl34QLOnHo0ZnX/tCjLEfa8mDbj0SR Aajt4DpzwBrMK+fnM0E2ECGAJkR1mtAd/KFCYmkYzyDIq/bw4givG91ot+rWhvhzBsuB RQoVXpTn+j5kL4n9JAkTV1zrvQ0McoOzah+l2dYft2O2exz7itBANH2bkUZKe34UiU7U zkng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717738855; x=1718343655; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iuce32N/yR5pZNPpV3osf/DDjXllQYyoW80CW+faFDE=; b=UE8RW1RXm6NwsiHTipYrK7X85fDAKNHtoxhbmPSpKv4MDkRXvfV78WehJRj4UE0wEa +6JC51flBygsKEvVE6GWIo3gZ0MkzE9EZBj5xZ3JClw5HT0+ophMDuoJN3ZQSOCQmeip DdzE6NdO4Ww6Z1TK2Pojc77bhTCt2NOmYOYs5rGKvaa7LvZL8se25i/Vc9dfp6Y6lI7s 1Ymz3qO0VQU8tQRSQsMKg/1YSanJMz/w8LbT3SxFHdnQ4QdowsNnmoQLYlRqujV5cxnu fIfh4jSwwAS90um2047u2c7x+pR8zF0/bVg4yw5DhWtfiFvNv6/Ew3TYK3yNVIHe1X5q M+Yg== X-Forwarded-Encrypted: i=1; AJvYcCVaM2+VOsZEwOSFaKw7QQYtLVifaen4/CKaOuRMU8aSaGH9zx2S14ATRyoM9XcYLWpaLCraMtBBe7I7g3bHTYIxp1mcJ6IXX1zb3oJKoCaDlV+v X-Gm-Message-State: AOJu0YwZT1Jqp7FPZ2iFPwSy4YcwDrjAyiEDNBNUZUxLUZYgc+eltFNV A0M5kEhovKkoWS1E6VDfTs2PLKkJFVRxwVGBeb0/G1JhP+MESwpXf/iTVrKiSkqi6NFVvvrpQVO TIZZ+8pAjRMlhHxwdSbui7Z4RE1k= X-Google-Smtp-Source: AGHT+IHY9zTpC+tkJTgShjVL1Hrkphst6Xamxkt2sUPBzfud30YTerCSyLaMGEmhkQqn8lgjAVbMU3fmm5quDFhSu38= X-Received: by 2002:a05:651c:1505:b0:2ea:aca0:2765 with SMTP id 38308e7fff4ca-2eadce281eamr14703921fa.5.1717738854910; Thu, 06 Jun 2024 22:40:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Muhammad Ikram Date: Fri, 7 Jun 2024 10:40:38 +0500 Message-ID: Subject: Re: Oracle to Postgres - Transform Hash Partition To: Christoph Moench-Tegeder Cc: David Barbour , pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000004393cd061a463e70" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004393cd061a463e70 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi David, Here is another approach. See if it serves your purpose postgres=3D# create schema idev; CREATE SCHEMA postgres=3D# postgres=3D# postgres=3D# CREATE TABLE idev.assessment_result_2023_dab ( district_oid int, -- other columns go here column1 numeric, column2 numeric ); CREATE TABLE postgres=3D# postgres=3D# CREATE TABLE idev.assessment_result_2023_dab_part ( LIKE idev.assessment_result_2023_dab ) PARTITION BY HASH (district_oid); CREATE TABLE idev.assessment_result_2023_dab_part_2023_p1 PARTITION OF idev.assessment_result_2023_dab_part FOR VALUES WITH (modulus 64, remainder 0); CREATE TABLE idev.assessment_result_2023_dab_part_2023_p2 PARTITION OF idev.assessment_result_2023_dab_part FOR VALUES WITH (modulus 64, remainder 1); CREATE TABLE idev.assessment_result_2023_dab_part_2023_p3 PARTITION OF idev.assessment_result_2023_dab_part FOR VALUES WITH (modulus 64, remainder 2); CREATE TABLE idev.assessment_result_2023_dab_part_2023_p4 PARTITION OF idev.assessment_result_2023_dab_part FOR VALUES WITH (modulus 64, remainder 3); CREATE TABLE idev.assessment_result_2023_dab_part_2023_p5 PARTITION OF idev.assessment_result_2023_dab_part FOR VALUES WITH (modulus 64, remainder 4); CREATE TABLE idev.assessment_result_2023_dab_part_2023_p6 PARTITION OF idev.assessment_result_2023_dab_part FOR VALUES WITH (modulus 64, remainder 5); CREATE TABLE idev.assessment_result_2023_dab_part_2023_p7 PARTITION OF idev.assessment_result_2023_dab_part FOR VALUES WITH (modulus 64, remainder 6); CREATE TABLE idev.assessment_result_2023_dab_part_2023_p8 PARTITION OF idev.assessment_result_2023_dab_part FOR VALUES WITH (modulus 64, remainder 7); CREATE TABLE CREATE TABLE CREATE TABLE CREATE TABLE CREATE TABLE CREATE TABLE CREATE TABLE CREATE TABLE CREATE TABLE postgres=3D# postgres=3D# postgres=3D# CREATE TABLE idev.temp_assessment_result_2023_dab AS TABLE idev.assessment_result_2023_dab WITH NO DATA; CREATE TABLE AS postgres=3D# postgres=3D# postgres=3D# INSERT INTO idev.temp_assessment_result_2023_dab SELECT * FROM idev.assessment_result_2023_dab; INSERT 0 0 postgres=3D# postgres=3D# postgres=3D# TRUNCATE TABLE idev.assessment_result_2023_dab; TRUNCATE TABLE postgres=3D# postgres=3D# ALTER TABLE idev.assessment_result_2023_dab_part ATTACH PARTITION idev.assessment_result_2023_dab FOR VALUES WITH (modulus 64, remainder 8); ALTER TABLE postgres=3D# postgres=3D# postgres=3D# INSERT INTO idev.assessment_result_2023_dab_part SELECT * FROM idev.temp_assessment_result_2023_dab; INSERT 0 0 postgres=3D# postgres=3D# DROP TABLE idev.temp_assessment_result_2023_dab; DROP TABLE postgres=3D# postgres=3D# Regrads, Muhammad Ikram bitnine On Thu, Jun 6, 2024 at 11:41=E2=80=AFPM Christoph Moench-Tegeder wrote: > ## David Barbour (dbarbour@istation.com): > > > Now I need to 'attach' the original table. The problem I'm running int= o > is > > there are no good examples of how to define the values. > > The syntax is the same as with CREATE TABLE ... PARTITION OF, e.g. > ALTER TABLE parent ATTACH TABLE part FOR VALUES WITH (MODULUS m, REMAINDE= R > r); > > > Here's an example: > > alter table idev.assessment_result_2023_dab_part > > attach partition idev.assessment_result_2023_dab for values with(modulu= s > 8, > > remainder 1) to (modulus 8, remainder 7) > > There's only one (modulus, remainder) tuple in the partition bound > definition for hash partitions, and always only one partition bound > specification per partition. > Maybe what you actually want is a DEFAULT partition (specified as > PARTITION OF parent DEFAULT), or maybe a completely different approach? > > Regards, > Christoph > > -- > Spare Space. > > > --=20 Muhammad Ikram --0000000000004393cd061a463e70 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi David,

Here is another approach. See= if it serves your purpose

postgres=3D# create sch= ema idev;
CREATE SCHEMA
postgres=3D#
postgres=3D#
postgres=3D= # CREATE TABLE idev.assessment_result_2023_dab ( =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
=C2=A0 =C2=A0 district_oid int,<= br>=C2=A0 =C2=A0 -- other columns go here
=C2=A0 =C2=A0 column1 numeric,=
=C2=A0 =C2=A0 column2 numeric
);
CREATE TABLE
postgres=3D# postgres=3D#
CREATE TABLE idev.assessment_result_2023_dab_part (
= =C2=A0 =C2=A0 LIKE idev.assessment_result_2023_dab
) PARTITION BY HASH (= district_oid);

CREATE TABLE idev.assessment_result_2023_dab_part_202= 3_p1 PARTITION OF idev.assessment_result_2023_dab_part
=C2=A0 =C2=A0 FOR= VALUES WITH (modulus 64, remainder 0);

CREATE TABLE idev.assessment= _result_2023_dab_part_2023_p2 PARTITION OF idev.assessment_result_2023_dab_= part
=C2=A0 =C2=A0 FOR VALUES WITH (modulus 64, remainder 1);

CRE= ATE TABLE idev.assessment_result_2023_dab_part_2023_p3 PARTITION OF idev.as= sessment_result_2023_dab_part
=C2=A0 =C2=A0 FOR VALUES WITH (modulus 64,= remainder 2);

CREATE TABLE idev.assessment_result_2023_dab_part_202= 3_p4 PARTITION OF idev.assessment_result_2023_dab_part
=C2=A0 =C2=A0 FOR= VALUES WITH (modulus 64, remainder 3);

CREATE TABLE idev.assessment= _result_2023_dab_part_2023_p5 PARTITION OF idev.assessment_result_2023_dab_= part
=C2=A0 =C2=A0 FOR VALUES WITH (modulus 64, remainder 4);

CRE= ATE TABLE idev.assessment_result_2023_dab_part_2023_p6 PARTITION OF idev.as= sessment_result_2023_dab_part
=C2=A0 =C2=A0 FOR VALUES WITH (modulus 64,= remainder 5);

CREATE TABLE idev.assessment_result_2023_dab_part_202= 3_p7 PARTITION OF idev.assessment_result_2023_dab_part
=C2=A0 =C2=A0 FOR= VALUES WITH (modulus 64, remainder 6);

CREATE TABLE idev.assessment= _result_2023_dab_part_2023_p8 PARTITION OF idev.assessment_result_2023_dab_= part
=C2=A0 =C2=A0 FOR VALUES WITH (modulus 64, remainder 7);
CREATE = TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CR= EATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
postgres=3D# =
postgres=3D#
postgres=3D# CREATE TABLE idev.temp_assessment_result_= 2023_dab AS TABLE idev.assessment_result_2023_dab WITH NO DATA;
CREATE T= ABLE AS
postgres=3D#
postgres=3D#
postgres=3D# INSERT INTO idev.= temp_assessment_result_2023_dab
SELECT * FROM idev.assessment_result_202= 3_dab;
INSERT 0 0
postgres=3D#
postgres=3D#
postgres=3D# TRUN= CATE TABLE idev.assessment_result_2023_dab;
TRUNCATE TABLE
postgres= =3D#
postgres=3D# ALTER TABLE idev.assessment_result_2023_dab_part
A= TTACH PARTITION idev.assessment_result_2023_dab
=C2=A0 =C2=A0 FOR VALUES= WITH (modulus 64, remainder 8);
ALTER TABLE
postgres=3D#
postgre= s=3D#
postgres=3D# INSERT INTO idev.assessment_result_2023_dab_part
= SELECT * FROM idev.temp_assessment_result_2023_dab;
INSERT 0 0
postgr= es=3D#
postgres=3D# DROP TABLE idev.temp_assessment_result_2023_dab;DROP TABLE
postgres=3D#
postgres=3D#


Regrads,
Muhammad Ikram
bitnine

=

On Thu, Jun 6, 2024 at 11:41=E2=80=AFPM Christoph Moench-Tegede= r <cmt@burggraben.net> wrot= e:
## David Barb= our (dbarbour@is= tation.com):

> Now I need to 'attach' the original table.=C2=A0 The problem I= 'm running into is
> there are no good examples of how to define the values.

The syntax is the same as with CREATE TABLE ... PARTITION OF, e.g.
ALTER TABLE parent ATTACH TABLE part FOR VALUES WITH (MODULUS m, REMAINDER = r);

> Here's an example:
>=C2=A0 alter table idev.assessment_result_2023_dab_part
> attach partition idev.assessment_result_2023_dab for values with(modul= us 8,
> remainder 1) to (modulus 8, remainder 7)

There's only one (modulus, remainder) tuple in the partition bound
definition for hash partitions, and always only one partition bound
specification per partition.
Maybe what you actually want is a DEFAULT partition (specified as
PARTITION OF parent DEFAULT), or maybe a completely different approach?

Regards,
Christoph

--
Spare Space.




--
Muhammad Ikram

--0000000000004393cd061a463e70--