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 1k2epU-0006it-5d for pgsql-general@arkaria.postgresql.org; Mon, 03 Aug 2020 18:04:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k2epT-0008Pf-4M for pgsql-general@arkaria.postgresql.org; Mon, 03 Aug 2020 18:04:55 +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 1k2epS-0008PY-Qv for pgsql-general@lists.postgresql.org; Mon, 03 Aug 2020 18:04:54 +0000 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k2epQ-0004No-N7 for pgsql-general@lists.postgresql.org; Mon, 03 Aug 2020 18:04:53 +0000 Received: by mail-oi1-x243.google.com with SMTP id k4so34047398oik.2 for ; Mon, 03 Aug 2020 11:04:52 -0700 (PDT) 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-transfer-encoding:content-language; bh=6lWiRb4JuKx3OVfYP8L5te3ygrnQEoEzPw4AloAP4tc=; b=b8bfq+GSszFDwv0xQQLxF3ybSTybX/2bo6teB8XAI/JnZKv3LlAed+Tj4KcbqXuHuj y+RGG08YMKW7VFNmf5s67370hHa5To/+Ruri8//jDXAUJ9BZVqHG04IDq4KBXH6U4HEk uuFpw5LN/QqJbHfyOSiNVGU40ftrScxaEEATVq7iJ4ZVTAhJFpf0SUujk98w3ak5dydv hchqPybQ/QLTX/6a7cSjk9U62VLw/YRHF6bMeLVyxrGr0Diuane055Tsc5lu7OG0fKYb VM4D6KCl97ZmMh06GpBwdBSXjiJUWEWyd9dV0TpncTc36HFVvtLrBZ/wCLsVoP3+itnD 1ekg== 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-transfer-encoding :content-language; bh=6lWiRb4JuKx3OVfYP8L5te3ygrnQEoEzPw4AloAP4tc=; b=HkSPEkyKM5R93KoCKehTetB3oC+acsyNKPfDVwB180gMyuuNL90PKXteakOjKdCvWe N2zicLgL1nbRrPngzb875dEMHV1K+YlLD8xiwj9YWaL3hEEYbl8insl98mAve/DfMrhP EuFiIcAOpyv2Apn4g0P4asHoS08xnWvNicDjwVDxwaH0r6vExkdZRsxpcB0ua35TjCYt HlL2JcZAdO74CJQrvW3yW0d+tc1AC+GBLVfy83pX/h9KS1uxPHs4Nq46GMbeQ5IZJbDN Q/Xb9W2gIV/GquFfEXA8bnEOIlj2gRlRgEPPjMhkSgwQBl02C8o3ok34HWtsDsNkC+ir oaow== X-Gm-Message-State: AOAM5304tVGPLWHwZLbHLeodvfalgVNyPcvw9s2S5OzATQGHSrzB43kh b3zsMbBL2aSd4ItZTSHO3R24YuJKbDU= X-Google-Smtp-Source: ABdhPJxc7uWWyXuZcyUO7FDM++m7PHlclEtPfhD11U4xZ6SK6z06a1p+eCgbdovjZYDE4uScv3tjlw== X-Received: by 2002:aca:de42:: with SMTP id v63mr451613oig.21.1596477890677; Mon, 03 Aug 2020 11:04:50 -0700 (PDT) Received: from [192.168.1.10] (ip70-186-126-197.no.no.cox.net. [70.186.126.197]) by smtp.googlemail.com with ESMTPSA id y73sm3130643ooa.25.2020.08.03.11.04.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Aug 2020 11:04:49 -0700 (PDT) Subject: Re: How to rebuild index efficiently To: pgsql-general@lists.postgresql.org References: <5131947A-0470-46C0-93B8-7AE07BBC22FA@thebuild.com> From: Ron Message-ID: Date: Mon, 3 Aug 2020 13:04:45 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <5131947A-0470-46C0-93B8-7AE07BBC22FA@thebuild.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 8/3/20 12:58 PM, Christophe Pettus wrote >> 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. Of course, you need enough disk space... :) -- Angular momentum makes the world go 'round.