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 1mRf55-0002vr-HC for pgsql-general@arkaria.postgresql.org; Sat, 18 Sep 2021 18:28:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mRf4X-000687-QI for pgsql-general@arkaria.postgresql.org; Sat, 18 Sep 2021 18:28:21 +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 1mRf4X-00067z-Hf for pgsql-general@lists.postgresql.org; Sat, 18 Sep 2021 18:28:21 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mRf4Q-0004ah-4o for pgsql-general@lists.postgresql.org; Sat, 18 Sep 2021 18:28:20 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 18IISBZc1492490; Sat, 18 Sep 2021 14:28:11 -0400 From: Tom Lane To: Tobias Meyer cc: pgsql-general@lists.postgresql.org Subject: Re: Remove duplicated row in pg_largeobject_metadata In-reply-to: References: <1488151.1631984508@sss.pgh.pa.us> Comments: In-reply-to Tobias Meyer message dated "Sat, 18 Sep 2021 19:58:42 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1492488.1631989691.1@sss.pgh.pa.us> Date: Sat, 18 Sep 2021 14:28:11 -0400 Message-ID: <1492489.1631989691@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tobias Meyer writes: > so I did > select ctid as tid,oid,lomowner into temp table temp_pgmeta from > pg_largeobject_metadata; > select * from ( select count(tid) as cnt,max(tid), min(tid), oid from > temp_pgmeta group by oid) x where cnt > 1; > and that gave me 2951857 rows Yipes. Did you verify that the TIDs are all distinct? A possible theory is that pg_largeobject_metadata_oid_index has been corrupt for a long time, allowing a lot of duplicate entries to be made. However, unless pg_largeobject's pg_largeobject_loid_pn_index is *also* corrupt, you'd think that creation of such duplicates would still be stopped by that unique index. There's something mighty odd here. regards, tom lane