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 1sdsDQ-001lTU-On for pgsql-general@arkaria.postgresql.org; Tue, 13 Aug 2024 14:09:36 +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 1sdsDP-0049tC-4Z for pgsql-general@arkaria.postgresql.org; Tue, 13 Aug 2024 14:09:35 +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 1sdsDO-0049t3-PQ for pgsql-general@lists.postgresql.org; Tue, 13 Aug 2024 14:09:34 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sdsDL-004Y5d-Va for pgsql-general@lists.postgresql.org; Tue, 13 Aug 2024 14:09:33 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-53212e0aa92so1566300e87.0 for ; Tue, 13 Aug 2024 07:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723558170; x=1724162970; 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=xCVKDLA07eir8KHCULVLzcLfAgk24FD/17KbwIF0XKg=; b=XrUBQdv6E0CAOe/vA5YAfPpEwdjGC/hDRA9LiT9eFAc0Q6KYBBlsue/4yZcpAH3XXc Z2kx7ebu938IhJI0970krMGwR6BGPEI9WgaAwtGCHbIT8y7KEu1MYXuUNUva2rU8sT33 bKe+dJgkJMWxN5Ix7wjF5PiWedaHjjfqFUUcADuNMi1iBCqObgq2ntV7ypnfa3Gx9X2B fkF7fjHXadLl1qaNV3+YJILDed9/zXkWKfSnh6c7XKlKhL10hzso8Mft/JwDKMVX4d5P q+zegq+4/zX9SR3eMNnB+zDdz+PgXdZVLB7d0KQ93dt1A6S46LS8RZHOseR68k+Slg/H +XDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723558170; x=1724162970; 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=xCVKDLA07eir8KHCULVLzcLfAgk24FD/17KbwIF0XKg=; b=lKZkvGUi3hu/6QO6xDQ1/zL86x4FqIjK/fyg1BShk6ENtUbzw1e50y2QDmLemwmCqa G4FZa7G8IYluzo7BbAnGwkdWCWmikyOvqnpdnnnZeZjqUZUAO473ub94wIXdQnCt2g6z /54ZlZXT8PCliOmEERseswRYy8Q4EcFjOT0dGa2ywVCAmkW4pOhP8cBv7dL6sGtWs3eI r77ooXqFR09CQ+ws91qF/yC3aMP2ysjwT2ltZ1K28sKvxm6g8EeFfmGUebkzRiEssxeM WYPKC6qFkNDkJ0SgI/eOFmUw30bFzOFeJ0o8MrEMNucXp3hDaDOVZ+GsN/417a9xTAIk AYGQ== X-Forwarded-Encrypted: i=1; AJvYcCWrX8Eaje9ZYI0pbgqRjhWpHh5J52Fbk5afTlHviCQXaqsXv1gfV8PCCdZP+qK3K4MQcucI8YsDlijaBHO4DBahPuyVIIJsl2N4R22kNvzRKjYZ X-Gm-Message-State: AOJu0YzZDi/5ONcpyA/d0xFM9j8MlJ4ceblSVjOTQNS8Tk13+1EgOSVn j1j/7ewFZTTEVL3zlW0gX/1IRQRGuYunlv9EvbibpuqZ/MsfxEAsmuVtG19pLnEwXd4IVQqS5Tw 8shMJ4QwKIjweW+8w+xAGYNdU01s= X-Google-Smtp-Source: AGHT+IFqY7fQCo4RYGPyKRGvcShPXSjSTkh1oMbFY7jU+Ye+qdUStTFy/EvOAoGN9YQFM3e/QXNDCu+8phcfKldioWI= X-Received: by 2002:a05:6512:3b8e:b0:530:c1fc:1c32 with SMTP id 2adb3069b0e04-53213692e21mr2549320e87.45.1723558169350; Tue, 13 Aug 2024 07:09:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Tue, 13 Aug 2024 10:08:52 -0400 Message-ID: Subject: Re: Column type modification in big tables To: Lok P Cc: sud , pgsql-general Content-Type: multipart/alternative; boundary="0000000000006f1dff061f91280e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006f1dff061f91280e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Aug 10, 2024 at 5:06=E2=80=AFPM Lok P wrote: > Can someone through some light , in case we get 5-6hrs downtime for this > change , then what method should we choose for this Alter operation? > We can't really answer that. Only you know what resources you have, what risk/reward you are willing to handle, and how long things may take. For that latter item, your best bet is to try this out on the same/similar hardware and see how long it takes. Do a smaller table and extrapolate if you need to. Or promote one of your replicas offline and modify that. I've given you a low-risk / medium-reward option with check constraints, but for the ALTER TABLE options you really need to try it and see (on non-prod). it seems the "USING" clause takes more time as compared to normal ALTER. > But again I don't see any way to see the progress and estimated completio= n > time. Can you share your thoughts on this? There should be no difference if they are doing the same conversion. Will this approach be faster/better as compared to the simple "alter table > alter column approach" as above Seems a lot more complicated to me than a simple ALTER. But measurement is key. Create a new test cluster using pgBackRest or whatever you have. Then run your ALTER TABLE and see how long it takes (remember that multiple columns can be changed in a single ALTER TABLE statement). Cheers, Greg --0000000000006f1dff061f91280e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sat, Aug 10, 2024 at 5:06=E2=80=AFPM L= ok P <loknath.73@gmail.com&g= t; wrote:
=C2=A0
Can someone through=C2=A0some light , in case we get 5-6hrs downtim= e for this change , then what method=C2=A0should=C2=A0we choose for this Al= ter operation?

We can= 't really answer that. Only you know what resources you have, what risk= /reward you are willing to handle, and how long things may take. For that l= atter item, your best bet is to try this out on the same/similar hardware a= nd see how long it takes. Do a smaller table and extrapolate if you need to= . Or promote one of your replicas offline and modify that. I've given y= ou a low-risk / medium-reward option with check constraints, but for the AL= TER TABLE options you really need to try it and see (on non-prod).

it seems the = "USING" clause takes more time as compared to normal ALTER. But a= gain I don't see any way to see the progress and estimated completion t= ime. Can you share your thoughts on this?

T= here should be no difference if they are doing the same conversion.

=C2=A0Will t= his approach be faster/better as compared to the simple "alter table a= lter column approach" as above

Seems a= lot more complicated to me than a simple ALTER. But measurement is key. Cr= eate a new test cluster using pgBackRest or whatever you have. Then run you= r ALTER TABLE and see how long it takes (remember that multiple columns can= be changed in a single ALTER TABLE statement).=C2=A0

<= div>Cheers,
Greg

--0000000000006f1dff061f91280e--