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 1nhvMn-0003mS-4d for pgsql-admin@arkaria.postgresql.org; Fri, 22 Apr 2022 15:38:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nhvMl-0002lu-RU for pgsql-admin@arkaria.postgresql.org; Fri, 22 Apr 2022 15:38:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nhvMl-0002lk-EW for pgsql-admin@lists.postgresql.org; Fri, 22 Apr 2022 15:38:39 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nhvMi-0001PG-Jq for pgsql-admin@postgresql.org; Fri, 22 Apr 2022 15:38:38 +0000 Received: by mail-qk1-x736.google.com with SMTP id c1so6027922qkf.13 for ; Fri, 22 Apr 2022 08:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crunchydata.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HcmgDobgZgGovPIh96D9eh0JbmxylHxNxrcUsl8AKKg=; b=bzPkIesb23rA0d/q5Kyja99HbnPBypte24Jcx2t4M87unbQd9V4fXjMNsbZWIxEJbC AG+no/YObcotrAcHQ+TQp0dVxvOjhVvFHtzpps20a4KylKZEJUSEykvxqn+/ocszaGmv RtggB5hZm1g3pnAtQgoFxitetMeNJcWuXryJ9zjquQWnYqOhEqpDDQMDVbb+Qaj+WH12 XCj9tbNX8waeDGOuWRalKv8R6KZ8sU1XrZK30AE3tapeJzQCiUqMjbobBwWMQcmoRg0A /p4i9x7n0AyUGctwWqTvynIy5byBHqyHyP1dcf2NrEzL9zaQxbxdMfXaPjxpYgJHU0aL xoyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HcmgDobgZgGovPIh96D9eh0JbmxylHxNxrcUsl8AKKg=; b=eSErNFGMR00MKEXFKUdz9JWZLeuZEI189NcRl94NKPR3kzO7av7Tm1ex2tJHukA48H TmvSu/jqefPXB55fzmSe1KOLAYtcY0Q/HWSwM5zVSLHN1SrPYQFo6O+cZUQuVRdG1y3n IT1mFpCe7OKMqsaoromJAxBa1FGBT0E8iiMBDYeDJ8TMG56ttnXsjtnb8pKtBDllsFif JMRapvj/7R/dbAM10QhwYh1WpbxTyZjV6LXoEHPZtUsAhgPItEJMPVUKXWmsC1Ojq//3 eZ3nG/TDGASTFb8y95wO3G9gndJQhV7Z6Lzzqe7KoKGkNkVmWFgpz58I6SWyxsOuVbh9 1lIw== X-Gm-Message-State: AOAM533xAfnEe9kRfykjtd7iPQp52mvBWcvQHkeOmkjuxXssi8SnvST1 2/QPGlGjNEOt02YLjZNXuDKCJDPYX7OJhOWbh5zx5Q== X-Google-Smtp-Source: ABdhPJzpOwGUY8zOVKixabg2V73GGgAxW2SP4Xfi4M9uGV5uKLc4v2Tcug8SoifUQi57MsWNgSDIakxax7DR1QmR3uc= X-Received: by 2002:a05:620a:14f:b0:69e:e6d2:9915 with SMTP id e15-20020a05620a014f00b0069ee6d29915mr3030044qkn.59.1650641913770; Fri, 22 Apr 2022 08:38:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Keith Fiske Date: Fri, 22 Apr 2022 11:38:08 -0400 Message-ID: Subject: Re: Partitioning without downtime To: Loles Cc: pgsql-admin Content-Type: multipart/alternative; boundary="000000000000ec12bb05dd400411" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ec12bb05dd400411 Content-Type: text/plain; charset="UTF-8" On Fri, Apr 22, 2022 at 11:28 AM Loles wrote: > Hi! > > Is there a way to partition a table in production without downtime? Or > extension that allows it. > > Thanks! > Zero downtime (or without a table lock at some point) is not possible with native partitioning since you cannot convert an existing table into a natively partitioned table. However, it is possible to do it with very little downtime if the circumstances allow. I've laid out a method of doing this with pg_partman here - https://github.com/pgpartman/pg_partman/blob/master/doc/pg_partman_howto_native.md -- Keith Fiske Senior Database Engineer Crunchy Data - http://crunchydata.com --000000000000ec12bb05dd400411 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Fri, Apr 22, 2022 at 11:28 AM Lole= s <lolesft@gmail.com> wrote:=
Hi!

Is there a way to parti= tion a table in production without downtime? Or extension that allows it.

Thanks!

Zero downtime (or without a table lo= ck at some point) is not possible with native partitioning since you cannot= convert an existing table into a natively partitioned table. However, it i= s possible to do it with very little downtime if the=20 circumstances allow. I've laid out a method of doing this with=20 pg_partman here -=C2=A0https://github.com/pgpartman/pg_= partman/blob/master/doc/pg_partman_howto_native.md

--
Keith Fiske
Senior Database Engineer
Crunchy Data -= http://crunchydata.co= m
--000000000000ec12bb05dd400411--