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 1uRnvY-00Ga6x-2Z for pgsql-general@arkaria.postgresql.org; Wed, 18 Jun 2025 08:13:48 +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 1uRnvV-00HA2A-OA for pgsql-general@arkaria.postgresql.org; Wed, 18 Jun 2025 08:13:46 +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 1uRa97-00BgOG-Hd for pgsql-general@lists.postgresql.org; Tue, 17 Jun 2025 17:30:54 +0000 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uRa96-002WvO-0C for pgsql-general@postgresql.org; Tue, 17 Jun 2025 17:30:52 +0000 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-32adebb15c5so51246691fa.3 for ; Tue, 17 Jun 2025 10:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750181450; x=1750786250; darn=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=1v/8fhjKK4iKjrxDNRbQy5zZ4KMT4QgIN6WMIufd+E8=; b=TZYv7/70PCKVM1SIa/CjwNObD24hVoa+wPgHQ0QKxbjeVa4HDGmROEooJLIULKiOmt Ta3J7V+Gs+rGFBpiYChUA5GD+L8FYVXfXyTzm7SX9+kYCLgvVEzI935U8k9DabYKd6D0 DNRKHoe+NCKkYTjnYlABFRCdOPgnL5dHNqUTeUX7L2W7hOV3A8Oe0FF2DULK3VYSwo+W SrSrAUd2E0dD8adaRwiyPoVz/qLj4w0PDGn/wgvlhmNToMWfdQ5f9PU+0dOIUgpOH9OB sFV3htsvUAcnARh9rHcfXqw0QD81IEtKEtqQiLHxVxgmgOknwhke1gOoRpjWrsaZYQZq SQGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750181450; x=1750786250; 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=1v/8fhjKK4iKjrxDNRbQy5zZ4KMT4QgIN6WMIufd+E8=; b=pqiX+CbeJsqaPwywbzxclIZ1QZ5XxaWKlMvIpODxX4yPi/v9Cky08PdHb+ESncU3ql kLsKTlBI6Cqj0oXQCd1V69gNNf2RdR7ix+rZxfXtEb7M6Hyj3uT2TdeEmXLFjsNwO0kl ONQZawDep//GAu6HLcbIOlnlgJbSn4d12yU9W6qfJVWVytd8rSeW01Vx9kjaNuQ7HCzt mwnFo4Vg/ZCqD0aV3R2mIc/b+U3E/wk3AhusUbDFcfanL9z/geUvaIBAAnkcBLQ5J2PX TWdefArPpu6EgaRhNsEXSMpFPVtXxs2uNrfcMHhKV07s861pcyWuEpBuPrKRFzZ4yzoi MPnA== X-Gm-Message-State: AOJu0YzPW3DWikdI2p85yzi6rdOzJxkjNNot6ky8F1ALUSJfWh5UZZ7r GcF2sBOQgZDNI3QZlJLXLYTJkq2GOcNbkJPcbGtVzQtpAnWhwqokEUkfAnr/6TYLqmuHxvtWN1W ZVHYmRyzJoEXF9Pk/Dc6YNGZV3U3g/8hJMT89 X-Gm-Gg: ASbGnct7vbkiNZZs2XhsYA59whHI85lGiTCyDyvz3Y0jYIuUpVnqYhA6YdHn6QjRfj7 jpCVenI5Sv3Zzt3hf0k/RX/163lyo7CfjJA3x3OepkaYCd8a6k5mDctRdfyQfy8frFoaEUNYgf4 EpOwF6CmehrGiBZDl8FjMdvw8fpa68E+nsmvPjmWOsde/I X-Google-Smtp-Source: AGHT+IGUcr3cc18Mpnzv+XRjXYK1WhuF1JeS7o3Kl7CCZGLmD/fXUWMdTSiJzsNvsqI9FCg4ii4N+rpfgumzbdjYuhA= X-Received: by 2002:a2e:a98c:0:b0:32a:8ae2:a8a7 with SMTP id 38308e7fff4ca-32b4a2c3186mr37892681fa.8.1750181449905; Tue, 17 Jun 2025 10:30:49 -0700 (PDT) MIME-Version: 1.0 References: <603f35e6-32b2-4044-bbfb-5e70bba5164b@aklaver.com> In-Reply-To: <603f35e6-32b2-4044-bbfb-5e70bba5164b@aklaver.com> From: Marcin Gozdalik Date: Tue, 17 Jun 2025 17:30:37 +0000 X-Gm-Features: AX0GCFuGtWBzBsWnn1VruJdkd61S7X_zrkaTCOE03p4UVpOIl469YzL_GfCaZ-c Message-ID: Subject: Re: Changing locale of an existing database To: Adrian Klaver Cc: pgsql-general@postgresql.org Content-Type: multipart/alternative; boundary="0000000000009d3a810637c7dff9" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000009d3a810637c7dff9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Around 100 DBs, ranging from 1TB to 50TB. Initial testing showed that it takes 1.5h to dump the DB and 3h to restore it for a DB of around 3TB. Just recreating the indexes takes around 30 minutes on the same DBs. I understand that pg_dump/pg_restore is the safe route but it's too slow for me so I'd like to understand if I have any alternative. wt., 17 cze 2025 o 16:55 Adrian Klaver napisa=C5=82(a): > On 6/17/25 09:20, Marcin Gozdalik wrote: > > Hi > > > > I am using PostgreSQL 17 and would like to take advantage of performanc= e > > and stability across OS updates of builtin C.UTF-8 locale. > > I have a cluster with a DB created with en_US.UTF-8 libc locale. I woul= d > > like to migrate the DB to C.UTF-8. Ideally there'd be an "ALTER DATABAS= E > > ... SET LOCALE ..." command that would take care of it but it seems it > > doesn't exist. I was thinking that I could change the collation of all > > TEXT/CHAR/VARCHAR columns in all the tables to pg_c_utf8, REINDEX all > > those columns and change the default locale in the pg_database table. > > > > Is it a sensible plan? Am I missing some steps? I can't find any > > reference to anybody doing that before or discouraging it. > > How big a database are we talking about? > > To me it would seem easier to create a new database with new locale and > do either a pg_dump/pg_restore or logical replication to the new > instance. Of course this may depend on the answer to the question above. > > > > > Thanks, > > Marcin > > > > -- > > Marcin Gozdalik > > -- > Adrian Klaver > adrian.klaver@aklaver.com > > --=20 Marcin Gozdalik --0000000000009d3a810637c7dff9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Around 100 DBs, ranging from 1TB to 50TB.
I= nitial testing showed that it takes 1.5h to dump the DB and 3h to restore i= t for a DB of around 3TB.

Just recreating the inde= xes takes around 30 minutes on the same DBs.

I und= erstand that pg_dump/pg_restore is the safe route but it's too slow for= me so I'd like to understand if I have any alternative.

=



--
Ma= rcin Gozdalik
--0000000000009d3a810637c7dff9--