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 1kmXe8-0003I3-7Y for pgsql-admin@arkaria.postgresql.org; Tue, 08 Dec 2020 07:42:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kmXe7-0001jA-0v for pgsql-admin@arkaria.postgresql.org; Tue, 08 Dec 2020 07:42:51 +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 1kmXe6-0001j3-NG for pgsql-admin@lists.postgresql.org; Tue, 08 Dec 2020 07:42:50 +0000 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kmXe4-0006pZ-K5 for pgsql-admin@lists.postgresql.org; Tue, 08 Dec 2020 07:42:50 +0000 Received: by mail-oi1-x233.google.com with SMTP id s2so9039208oij.2 for ; Mon, 07 Dec 2020 23:42:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=LZTriPO/2jBbSX41g14umA9JuWIRqtd/2ENK6LahVOU=; b=q2mgV1xFdQ2fmPEXnlCzxrxbpzESlVAIKVjXNpsDIzVxlPXRMfKwysBI/NwO2hunwe 7IlbTaptHSu0a0m3A0GlJHaSOtbBwSFIyA772jSPoCTS0+oNP1isgL8/HE+M/DxCo2ZY JaKUXsA2xcDz9bZokyDlahJQQ601C8PFOY52GG/Ngx2ldDKvHDFZQr5VRvOlI7dIpEEI Bg+L6DP70YISMgoklrmdjEyU5t0MCWCy8OIlUVRTU2Y+s1rwbAWJfLoX0E/WiRktOda8 Zlr2wd64NDTK1mKRbMnwdoIXeeGXFd4QVySLiSUIonkirqlET7va3uSu8iToOkQXC9b7 COZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=LZTriPO/2jBbSX41g14umA9JuWIRqtd/2ENK6LahVOU=; b=kZZ5Vq2uod/yGpoJZNvdZzC5lms+0unJ6kl6ZiksC9WbwpJWEqEP6m2wPnNdqQselk 2sMmE9bCU1s645kgJauMe8pWaYEwV/ZdiB00+xzFQgYuCYlBnmssic5rhXZcBfpHvhFT t9kx31MEsr8Z807I+8aw0u8xVFchpOoMfoXCmpL8XbAdsZtgDvtbpIFgbiuW4rikPxut CCF12QuSLFSTLk2HAFUGNtbE1W8/KgvB/S6Ho9KkAhTuvjrpm+fsJsE4nKpglJipc6W1 N3XUUOxUc0q+thK+9F7hzQN0DA0xt8JGwranRXajH2nDq4St2f60B3CHK91iyBA+KFBI +Dlw== X-Gm-Message-State: AOAM533mD9A4t0yJcZ6g+kjHxsO24KtMB3aQsXxD2LQLi0ry9PtS3Jzi c7k7NFi0tVL7KoUUjrR5XwasF44WFw38ow== X-Google-Smtp-Source: ABdhPJz42T/lszTxA/0kudwGaPyhZAOiGnphWp4rKBui0UQHvN2LYu5hkFHiMG1TD9T3AnxfSXVC0Q== X-Received: by 2002:aca:cc01:: with SMTP id c1mr1850396oig.18.1607413365644; Mon, 07 Dec 2020 23:42:45 -0800 (PST) Received: from [192.168.1.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id x31sm275074otb.4.2020.12.07.23.42.44 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Dec 2020 23:42:44 -0800 (PST) Subject: Re: reindexing db To: pgsql-admin@lists.postgresql.org References: <292966DF-135C-4483-81A9-5027FC3C8A82@elevated-dev.com> <214E5DBC-1F6F-49C1-8B83-9A2EB33E969A@gmail.com> <39a8cdb5-bfbb-9ae8-5867-c4234373277c@gmail.com> From: Ron Message-ID: <98c19d44-8d4c-f608-5432-eef048965552@gmail.com> Date: Tue, 8 Dec 2020 01:42:44 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------1ACBB74B8C9EE8F66C7BB950" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------1ACBB74B8C9EE8F66C7BB950 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 12/8/20 1:21 AM, Paul Förster wrote: > Hi Ron, > >> On 08. Dec, 2020, at 07:59, Ron wrote: >> >> Probably a habit from my VAX/VMS days, but I prefer to enumerate every table, not only for tracking but so that if the command fails 90% of the way through, I can skip over the the completed portions. > doing this IMHO defeats the purpose of concurrency because you'd have to issue reindex statements sequentially. Also, but I definitely can't say for sure, reindexdb should skip and report indexes which it has a problem with and then continue to do the remaining indexes. But as I said, I may be wrong with this. The CONCURRENTLY clause is about rebuilding *an index* online instead of blocking all other access to the table, not about reindexing multiple tables in parallel. Thus, it's perfectly valid to write something like DB=test while read line; do     psql $DB "REINDEX TABLE $line CONCURRENTLY;" done < list_of_tables.txt You might also be able to play with GNU Parallel and concurrently run multiple "REINDEX TABLE $line CONCURRENTLY;" statements. -- Angular momentum makes the world go 'round. --------------1ACBB74B8C9EE8F66C7BB950 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

On 12/8/20 1:21 AM, Paul Förster wrote:
Hi Ron,

On 08. Dec, 2020, at 07:59, Ron <ronljohnsonjr@gmail.com> wrote:

Probably a habit from my VAX/VMS days, but I prefer to enumerate every table, not only for tracking but so that if the command fails 90% of the way through, I can skip over the the completed portions.
doing this IMHO defeats the purpose of concurrency because you'd have to issue reindex statements sequentially. Also, but I definitely can't say for sure, reindexdb should skip and report indexes which it has a problem with and then continue to do the remaining indexes. But as I said, I may be wrong with this.

The CONCURRENTLY clause is about rebuilding an index online instead of blocking all other access to the table, not about reindexing multiple tables in parallel.

Thus, it's perfectly valid to write something like

DB=test
while read line;
do
    psql $DB "REINDEX TABLE $line CONCURRENTLY;"
done < list_of_tables.txt


You might also be able to play with GNU Parallel and concurrently run multiple "REINDEX TABLE $line CONCURRENTLY;" statements.

--
Angular momentum makes the world go 'round.
--------------1ACBB74B8C9EE8F66C7BB950--