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 1seciB-009kLA-UN for pgsql-general@arkaria.postgresql.org; Thu, 15 Aug 2024 15:48:27 +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 1seciA-00055y-Ag for pgsql-general@arkaria.postgresql.org; Thu, 15 Aug 2024 15:48:26 +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 1seci9-000559-VS for pgsql-general@lists.postgresql.org; Thu, 15 Aug 2024 15:48:25 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1seci7-004stl-Kr for pgsql-general@lists.postgresql.org; Thu, 15 Aug 2024 15:48:24 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a7aa212c1c9so136774566b.2 for ; Thu, 15 Aug 2024 08:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723736902; x=1724341702; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fZ3x4tHP3l/YlJgovR1xCHkhsCCcHg1D63OK2cHKXb8=; b=bamkpyNmPhRUdcH1BP/Cxs/6R+ICDdwOVDWyEZKBHFpxQgfqcTA6Y+Kte+SITKI0CT SRe/lLjcVQnqvajP87d+pDN/rbwLTb13Rx9zhIsHEEZ2Fo2LMrqPeuWmAQtK+P/HhFQM WrZ/6jvJeT7VYwhXi8ou/n9PIeOGiDs4dbSNdXYAy1Dpp53HH63w1TaEoCCK1bmavL4b UzAaWPrRgvJ1Eg1zCBQUTqWzQwyjPDS7j78k7CioDKjpqE9okGSbgA+BC9AI+gIkoJYl c87qSiIqe6q9bk48TlJR+9s0awyW843Of+l65/Lf2jcqsxFBLkn7HzBpyFX1s3uaO2cb 2kIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723736902; x=1724341702; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fZ3x4tHP3l/YlJgovR1xCHkhsCCcHg1D63OK2cHKXb8=; b=szMLcvn691Tnqs0fpAJXC6q2rNqAtRKGUTb0wQ+iHXwDBgtVXu4ajm06Jd637PeVxN E3uorpJSHy57TpAF5P5yr3gIUbRYDRpvljn9l4419RSOTLWVBSHVqaGVw7NDeSG4H46a PnIn9j0OXdQ6xB/I2aFqs+WvM88pFYM/IMbVDGXsCZami71G6uh8MqLQT9l5zM9JeT38 KtMtMtlbOLzMVqu2fcjjd0BSw5Vqwfa/yYUkQ0ubBOtzpHVKv6vivvRp4iBl9MVeWSVd UcDiXRPzyg9o/a3tie+JqUPiPD0hytizhRbc1S8YHsc7OsRVMJKP6F1E4bxoSsSxGXka ytCA== X-Forwarded-Encrypted: i=1; AJvYcCWqZV4YcanPGnptp4eK53pp6dbNoYHZ0eniLsX153FNrIJ2ySeJXZsXp3BNe9C0auILpA1FmJ6hmV4En6VsQ18c0vkkxh200HHsouATLp7e3A3E X-Gm-Message-State: AOJu0Yy+BpUbn1RG763p6USGDuUmg0dXmDDV9FK6t7Rii17hQ1bpZ+1O QTrNA8KychaUsWHqpuvrZQBmBJwt3hQHa1u/Ur1zNJL3cmbh66je X-Google-Smtp-Source: AGHT+IE0ShopMXTnBhChx1Wz701wfKu+jyvlzsI7WBmhdmsNVzQ5PYn/HQJPlxTyyZNvOi4z8ieJkA== X-Received: by 2002:a17:907:e24d:b0:a7a:acae:340e with SMTP id a640c23a62f3a-a8392932543mr2581666b.26.1723736901725; Thu, 15 Aug 2024 08:48:21 -0700 (PDT) Received: from smtpclient.apple ([188.212.112.125]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a838396d332sm118230866b.224.2024.08.15.08.48.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Aug 2024 08:48:21 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Subject: Re: Column type modification in big tables From: Alban Hertroys In-Reply-To: Date: Thu, 15 Aug 2024 17:48:10 +0200 Cc: Greg Sabino Mullane , sud , pgsql-general Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Lok P X-Mailer: Apple Mail (2.3776.700.51) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 15 Aug 2024, at 14:15, Lok P wrote: (=E2=80=A6) > Hello Greg,=20 >=20 > In terms of testing on sample data and extrapolating, as i picked the = avg partition sizeof the table (which is ~20GB) and i created a non = partitioned table with exactly same columns and populated with similar = data and also created same set of indexes on it and the underlying = hardware is exactly same as its on production. I am seeing it's taking = ~5minutes to alter all the four columns on this table. So we have ~90 = partitions in production with data in them and the other few are future = partitions and are blank. (Note- I executed the alter with = "work_mem=3D4GB, maintenance_work_mem=3D30gb, = max_parallel_worker_per_gather=3D8, max_parallel_maintenance_worker =3D16"= ) >=20 > So considering the above figures , can i safely assume it will take = ~90*5minutes=3D ~7.5hours in production and thus that many hours of = downtime needed for this alter OR do we need to consider any other = factors or activity here?=20 Are all those partitions critical, or only a relative few? If that=E2=80=99s the case, you could: 1) detach the non-critical partitions 2) take the system down for maintenance 3) update the critical partitions 4) take the system up again 5) update the non-critical partitions 6) re-attach the non-critical partitions That could shave a significant amount of time off your down-time. I = would script the detach and re-attach processes first, to save some = extra. Admittedly, I haven=E2=80=99t actually tried that procedure, but I see = no reason why it wouldn=E2=80=99t work. Apart perhaps, from inserts happening that should have gone to some of = those detached partitions. Maybe those could be sent to a =E2=80=98default= =E2=80=99 partition that gets detached at step 7, after which you can = insert+select those from the default into the appropriate partitions? But you were going to test that first anyway, obviously. Alban Hertroys -- There is always an exception to always.