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 1k2ej7-0006Nm-1f for pgsql-general@arkaria.postgresql.org; Mon, 03 Aug 2020 17:58:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k2ej5-0004Db-5w for pgsql-general@arkaria.postgresql.org; Mon, 03 Aug 2020 17:58:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k2ej4-0004DU-N2 for pgsql-general@lists.postgresql.org; Mon, 03 Aug 2020 17:58:18 +0000 Received: from smtp91.iad3b.emailsrvr.com ([146.20.161.91]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k2ej2-0004Ky-FE for pgsql-general@lists.postgresql.org; Mon, 03 Aug 2020 17:58:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=g001.emailsrvr.com; s=20190322-9u7zjiwi; t=1596477495; bh=0axHcHizMJhqWXnXHz7rmEaPJ3gT9VQ+wdCoZNoXdUY=; h=Subject:From:Date:To:From; b=I4A1lcck6kaiHDf4Ij1bVWnB+qAT5Ny+PRN/6QUSFbUqnLExBqMPi40uK2hsHjOVW On4Ph4YouCT3qp73N7Ad95NZQr6/P2AHnKzDsqSUJ3geKzEM2GCdNijthz3cTM/ZhJ FlCn2qFZU6ab1GLwdynixDAGInb53Hn2xqAHNFNg= X-Auth-ID: xof@thebuild.com Received: by smtp4.relay.iad3b.emailsrvr.com (Authenticated sender: xof-AT-thebuild.com) with ESMTPSA id D90D1202BB; Mon, 3 Aug 2020 13:58:14 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.5\)) Subject: Re: How to rebuild index efficiently From: Christophe Pettus In-Reply-To: Date: Mon, 3 Aug 2020 10:58:13 -0700 Cc: "pgsql-generallists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <5131947A-0470-46C0-93B8-7AE07BBC22FA@thebuild.com> References: To: Konireddy Rajashekar X-Mailer: Apple Mail (2.3445.9.5) X-Classification-ID: 10095182-b2ef-4d1a-b6f5-041d9ae5d3b3-1-1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Aug 3, 2020, at 10:20, Konireddy Rajashekar = wrote: > Could you please suggest any ideal approach to tackle this ? You can do CREATE INDEX CONCURRENTLY to build a new index with the same = definition, and when that is complete, drop the old index. The locking = that is required here is modest: CREATE INDEX CONCURRENTLY needs to lock = the table briefly at a couple of points in the operation, and dropping = the old index requires a brief lock on the table. It is, however, much = less overall lock time than REINDEX would be. -- -- Christophe Pettus xof@thebuild.com