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 1oJcGT-0006lL-19 for pgsql-admin@arkaria.postgresql.org; Thu, 04 Aug 2022 14:55:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oJcGR-0006aj-QD for pgsql-admin@arkaria.postgresql.org; Thu, 04 Aug 2022 14:55:55 +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 1oJcGR-0006VO-BV for pgsql-admin@lists.postgresql.org; Thu, 04 Aug 2022 14:55:55 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oJcGP-0001L8-7K for pgsql-admin@lists.postgresql.org; Thu, 04 Aug 2022 14:55:54 +0000 Received: by mail-oi1-x229.google.com with SMTP id p132so23459248oif.9 for ; Thu, 04 Aug 2022 07:55:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=pHOh68/A6hiJXK8/cSkYlAzlhkZEOyTKbKm3MCCzjbY=; b=WsH9wBSkp/Q3qZHENhGbIHbBFZ+oKzxac0DBarM7wlIBf96y7GctqWTrdp6aJ0BX3/ /KdeQSyUicrKWcQNluBLqTuiazEOAb2GZys4GD0pn2D+rLgVBVzcbSlio2vfKSKmlPnH 702eyrLC5xrsPtgGeudIq8xXVozLwFGtQeM36hqAIg7JomKCT7b+QRaHn+bNd3jV5kJS bJtZead3Onknp55PRwfqpRccpR17GUBtqPj0U/H68sbvGSzEXFn2b4k2l/mg9KI+puE6 bFgnZPjcMMuHMohTlnuinST6TvOSBDJzPVE2gKbVZjRV7vyXgtdDrGM7iYvlx2eY+DsD ZE/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=pHOh68/A6hiJXK8/cSkYlAzlhkZEOyTKbKm3MCCzjbY=; b=NFpQdi1oR/pCRcX/N966sVhW74MSI57m8GfWLNH/RnviAapjab4WcGyWf7MzeYjjvR HIJ0qDD66MkRivsUTbdKj5wv3o/m8Qz9KU77vl/M3UI6fin6Pe/ZwX/PV0V0uqwJ2svo kK1XFtNH+84lRW6fcQ3xWupMLS8reqlzlvapz0Ri+nPqSDWkZgW3UJQnNstKjy+OW05C B/DG4TA1YPhZseYNJlfFgg09uRWF1qJwbw6Cl8veL/pKh/VgsZvfA141GTahUgCsuUKB tIqHIUVlz3D/Lo3xQVOutih+ngYeLkAbnxBj/+bORR5IQgqHY9/CAvnvL4OJjkN2bnFd wdXA== X-Gm-Message-State: ACgBeo0imG8LjDpnUcDfULMUdIqoYu+uOug3l8sf+kKGqAhb4nwhDZhF 58qfh6kDnv12PrC19uYwa+0IWz1Shho= X-Google-Smtp-Source: AA6agR7q4+uznHBPhMKHBh/DPOTWPG8zTc5y5GXZStCScfDopzL7nxQWxoL+42gAR1mNvVqI5Thw9A== X-Received: by 2002:aca:e0d7:0:b0:33a:afba:2cd7 with SMTP id x206-20020acae0d7000000b0033aafba2cd7mr1011282oig.81.1659624951073; Thu, 04 Aug 2022 07:55:51 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id q8-20020a056830232800b0061c4a7a37fasm171038otg.41.2022.08.04.07.55.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Aug 2022 07:55:50 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------vLWPIgcga8bDIgNQJ34Q33NK" Message-ID: <5816758c-a8e5-1076-5c9f-7e59539f0696@gmail.com> Date: Thu, 4 Aug 2022 09:55:50 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: Determining Indexes to Rebuild on new libc Content-Language: en-US To: pgsql-admin@lists.postgresql.org References: From: Ron In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------vLWPIgcga8bDIgNQJ34Q33NK Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 8/4/22 09:29, Don Seiler wrote: > Good morning, > > As we're staring down the eventuality of having to migrate to a newer OS > (currently on Ubuntu 18.04 LTS), we're preparing for the collation change > madness that will ensue. We're looking at logical replication but there is > a lot to unpack there as well given the number of databases and the > massive size of a few of them. I had been inclined to bite the bullet and > do logical replication (or dump/restore on smaller DBs) but the timeframe > for the project is being pushed up so I'm looking for shortcuts where > possible (obviously without risking DB integrity). This would also give me > the opportunity for other modifications like enabling data checksums on > the new DBs that I had been sorely wanting for years now. > > One question that gets asked is if we could do physical replication, cut > over, and then only rebuild indexes that "need it" in order to minimize > the subsequent downtime. i.e. can we determine which indexes will actually > have a potential problem. For example, a lot of indexes are on > text/varchar datatype fields that hold UUID data and nothing more (basic > alphanumeric characters and hyphens embedded). If we can be certain that > these fields truly only hold this type of data, could we skip rebuilding > them after the cutover to a newer OS (eg Ubuntu 22.04 LTS with the newer > libc collation)? Join pg_indexes to information_schema to get only the indices with character fields. If *ALL* your UUID indices helpfully have "uuid" embedded in their names, then you can exclude them, too. Otherwise, you must scan each indexed text field looking for anything besides low-ASCII characters, and hope that no such data has been added to since you scanned. For example: SELECT field_1 from foo where field_1 >= CHR(128); CHECK constraints would of course also ensure that it can never happen... -- Angular momentum makes the world go 'round. --------------vLWPIgcga8bDIgNQJ34Q33NK Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit On 8/4/22 09:29, Don Seiler wrote:
Good morning,

As we're staring down the eventuality of having to migrate to a newer OS (currently on Ubuntu 18.04 LTS), we're preparing for the collation change madness that will ensue. We're looking at logical replication but there is a lot to unpack there as well given the number of databases and the massive size of a few of them. I had been inclined to bite the bullet and do logical replication (or dump/restore on smaller DBs) but the timeframe for the project is being pushed up so I'm looking for shortcuts where possible (obviously without risking DB integrity). This would also give me the opportunity for other modifications like enabling data checksums on the new DBs that I had been sorely wanting for years now.

One question that gets asked is if we could do physical replication, cut over, and then only rebuild indexes that "need it" in order to minimize the subsequent downtime. i.e. can we determine which indexes will actually have a potential problem. For example, a lot of indexes are on text/varchar datatype fields that hold UUID data and nothing more (basic alphanumeric characters and hyphens embedded). If we can be certain that these fields truly only hold this type of data, could we skip rebuilding them after the cutover to a newer OS (eg Ubuntu 22.04 LTS with the newer libc collation)?

Join pg_indexes to information_schema to get only the indices with character fields.

If ALL your UUID indices helpfully have "uuid" embedded in their names, then you can exclude them, too.

Otherwise, you must scan each indexed text field looking for anything besides low-ASCII characters, and hope that no such data has been added to since you scanned.

For example: SELECT field_1 from foo where field_1 >= CHR(128);

CHECK constraints would of course also ensure that it can never happen...

--
Angular momentum makes the world go 'round.
--------------vLWPIgcga8bDIgNQJ34Q33NK--