Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j7LSv-0002Qi-DG for pgsql-general@arkaria.postgresql.org; Thu, 27 Feb 2020 15:52:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j7LSt-0006xt-54 for pgsql-general@arkaria.postgresql.org; Thu, 27 Feb 2020 15:52:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j7LSs-0006wU-Ra for pgsql-general@lists.postgresql.org; Thu, 27 Feb 2020 15:52:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j7LSq-0005fG-Lu for pgsql-general@postgresql.org; Thu, 27 Feb 2020 15:52:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 01RFqa61021996; Thu, 27 Feb 2020 10:52:36 -0500 From: Tom Lane To: Kouber Saparev cc: pgsql-general@postgresql.org Subject: Re: Is it safe to rename an index through pg_class update? In-reply-to: References: Comments: In-reply-to Kouber Saparev message dated "Thu, 27 Feb 2020 16:54:34 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21994.1582818756.1@sss.pgh.pa.us> Date: Thu, 27 Feb 2020 10:52:36 -0500 Message-ID: <21995.1582818756@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Kouber Saparev writes: > Renaming an index the classical way through "ALTER INDEX xxx RENAME TO yyy" > needs an AccessExclusiveLock over the table holding the index (at least on > 9.3 it does). Instead, couldn't I simply: > UPDATE pg_class SET relname = 'yyy' WHERE oid = 'xxx'::regclass; There's a lot of stuff like that that you can probably get away with... but I'm not sure it's prudent to try it on valuable production data. If it breaks your database nobody is going to have any sympathy for you. FWIW, I can't immediately think of a reason this would cause a problem, at least not on 9.4 and up which use MVCC catalog scans. If you're really still on 9.3 then it's notably more risky. In any case, I've not had any caffeine yet today, so this doesn't count for much. regards, tom lane