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 1uS9I9-0041EY-Lq for pgsql-admin@arkaria.postgresql.org; Thu, 19 Jun 2025 07:02:33 +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 1uS9I7-008jzA-Ot for pgsql-admin@arkaria.postgresql.org; Thu, 19 Jun 2025 07:02:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uS9I7-008jz2-CA for pgsql-admin@lists.postgresql.org; Thu, 19 Jun 2025 07:02:32 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uS9I6-002peR-0I for pgsql-admin@lists.postgresql.org; Thu, 19 Jun 2025 07:02:30 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-32b7f41d3e6so3953221fa.1 for ; Thu, 19 Jun 2025 00:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750316548; x=1750921348; 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=DkgVwDr7e6DXnHqox7p0DLfUnK5H8ERIvaFX+KyibbQ=; b=eO+5N4UZL6QFx9hcsDBZSK+y4uT76TLGF1ndhPMLlzg/pGfAVc5MvQCLiA/48wrNjG JLFKTZcods0OoBtK6Df63saA+rzVIlRlQ7JP5onTlyqR5cstnJFn2hlNriZ5TufPG7C/ xQaMENjc14CcLzwA7gltI826m5mQMtISrumA47JBTYtOM9TM2GkoAHh9nAMFZUdO8YtU 9ZNIjPLKPase4cUfLVWOkYHuf+xKZANP5lVnyzsclzkZq8IMkqq6HMgsi/Gj5pft3Rky Vcs/FPzIfKrXhcxoeSoZF3rIjxvgVWd4Ib+BB4XPsnGTpnfeiYCRVHnVRBjFbo2jzbHl As4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750316548; x=1750921348; 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=DkgVwDr7e6DXnHqox7p0DLfUnK5H8ERIvaFX+KyibbQ=; b=KaiPYqYM1GuIt6FUxZyl0X1kzQLkEaRTT7oel7G+r+Dg/wk8/JCAgHuytRz4Oh/8pb hBW18mvz0w2ts0ttxnEEiGHSU63t23kCjvxK1CVrExATEvZwk5Shx9s0nwDir3ico/Ji owHHwlcXvBzKPjBlbkpHH6jlZX8I34Ba1NlP/00M6TQQBq9Cr9QgR8tb8m6wud/v6fYS U1w0fRZyhKbGh2xk4zJUnzFDi7fN1c6SAGwwie5t3z7prgN31WH5CvgHs0l+WApLxpAk AOeSZ5t6BEN5FBxzjFhvdcuFpVXInu5bkJ/x9oqw+yXmXLdPBsPOeWI0q9Ba5V/Me0z/ M/Kw== X-Gm-Message-State: AOJu0YySsTbjlBwry7cz6o7gkLYXt8HKMgghB9nSDxRoL1TaqZPo792k zuxQmuHPrFFL/NRw95nyU16T0rte4lsPGCz8PEVX3kXlccO6dJ5FJKoTFGpwhYCHdeMCls3tTx/ dKRwkm/vPrUc783SVHo9XIuywhoDg38M= X-Gm-Gg: ASbGncvfagu2m72A5S3I90QB9u24oPBh3D5RKFUBUQZvOZ4MxRXzPXoeq9FnXJDkW4U DCBSM4bo8quLgeSEdbSwGUcMQWP1uuHJ48qC4pw5K9J/6vvYnJIbaeaayKEMLQ6xvULcs3xWCHj TuxbS7qLa9RJLOKUE95/y8Bx2GqVka9tbFS1qCt56h6K8eq1PNPWQgKw== X-Google-Smtp-Source: AGHT+IHWJDvjgRee8kT3/pT2i/OnMfWxFqBUKkcoejk+36ea8J0tcphJOEkn1GWiPTB1mrbNwfLJxD/uDRF+xgCgYto= X-Received: by 2002:a2e:a36d:0:b0:32b:5795:7c29 with SMTP id 38308e7fff4ca-32b87ae4f90mr5165051fa.17.1750316548264; Thu, 19 Jun 2025 00:02:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: akshay polji Date: Thu, 19 Jun 2025 12:31:51 +0530 X-Gm-Features: AX0GCFuFKm8igUJTYI4lDRbHjDwoZP7pDjzUaonBCROpnTtl462hbOECrPyF8Qw Message-ID: Subject: Re: alter the datatype of Partition Key To: Gambhir Singh Cc: Pgsql-admin Content-Type: multipart/alternative; boundary="0000000000001a9a4d0637e754ca" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000001a9a4d0637e754ca Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable The cleanest way to do this would be to create a new table with varchar datatype for the partition key along with the partitions and then move the data partition-by-partition. The rollback would be super easy as well in case some issues arise in applications due to change of datatype. Regards, Akshay On Mon, Jun 16, 2025 at 6:47=E2=80=AFPM Gambhir Singh wrote: > Please help me on this > > Thanks & Regards > Gambhir Singh > > > > On Mon, 16 Jun 2025 at 12:45, Gambhir Singh > wrote: > >> Hi, >> >> We have a partition table with partitioning type range and got the >> requirement from the application team to alter the datatype of partition= ing >> key from bigint to varchar. Please suggest to me the way how this can be >> achieved. >> >> Data volume is quite huge in the table. ~50 Billion rows >> >> -- >> Thanks & Regards >> Gambhir Singh >> >> --0000000000001a9a4d0637e754ca Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The cleanest way to do this would be to create a new table= with varchar datatype for the partition key along with the partitions and = then move the data partition-by-partition.=C2=A0
The rollback would be = super easy as well in case some issues arise in applications due to change = of datatype.=C2=A0

Regards,
Akshay=C2=A0=

On Mon, Jun 16, 2025 at 6:47=E2=80=AFPM Gambh= ir Singh <gambhir.singh05@g= mail.com> wrote:
Please help me on this

T= hanks & Regards
Gambhir Singh


On Mon, 16 Jun 2025 at 12:45, Gambhir Singh <gambhir.singh05@gmail.com>= ; wrote:
Hi,

We have a partition table with part= itioning type range and got the requirement from the application team to al= ter the datatype of partitioning key from bigint to varchar. Please suggest= to me the way how this can be achieved.
Data volume is quite huge in the table. = ~50 Billion rows

--
Thanks & Regards
Gambhir Singh

<= /div>
--0000000000001a9a4d0637e754ca--