Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vklWM-001rYR-0s for pgsql-general@arkaria.postgresql.org; Tue, 27 Jan 2026 16:02:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vklWK-00EY2I-2i for pgsql-general@arkaria.postgresql.org; Tue, 27 Jan 2026 16:02:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vklWJ-00EY2A-34 for pgsql-general@lists.postgresql.org; Tue, 27 Jan 2026 16:02:24 +0000 Received: from fout-b7-smtp.messagingengine.com ([202.12.124.150]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vklWG-00000000jDL-3Sgz for pgsql-general@lists.postgresql.org; Tue, 27 Jan 2026 16:02:23 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id D975E1D00056; Tue, 27 Jan 2026 11:02:18 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Tue, 27 Jan 2026 11:02:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1769529738; x=1769616138; bh=KBlcfrmA70jrBxf/pjOCxMDcClRQoMDtiGoj9Fspr3k=; b= GrZPR7+N1kvijEpeN75Qcaux/szCuU61cQ/3nP4/Otu4p3llpxwNB/ke/FpSSLxf RIH9BT54ZxVWlIpEMRcMZ68DFSDXgUqoNAo6gMLyDaCMOL4bw3xcAsZ0+d2r4pcI BCmv8zgi1jLx+eoaf0R46Dfp7td8ajv1xipssUSYyRGmfVDxugaSf0g6afGFItpe iRH0rQAf9aIuaWDgtN8jKnomV0nrXmK+s5Pe0f9SZml+dTH+FAvaefHvzIHrKKaB 7OxrNTCtliYrlHb5HRGMYmYQa44epyFozb3C20qGkbJrqj4jjPV8vEgoDg9sf4Pv LkNqeg4XwfiVEI/dX6Ox/g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1769529738; x= 1769616138; bh=KBlcfrmA70jrBxf/pjOCxMDcClRQoMDtiGoj9Fspr3k=; b=h khFo6wBoJj/s6lqq5USAmsIekKfLQ5so0P9rdN4tfBvpR0IRNKFt/DKAURvt025X rCT4bk5HYV1UjPvKtZVDUJ6I7eBTJQQwuf3UvX/BhoB2wTDn3v+nBbIk6BpdytP9 0wbwxPkMQm4+ahVqdvifV4AnC4uxQB7r/GMhNW5uVydCv2JTX6ddvwiCuisWtwFB JbWIWasvD7xZeoyidWt31+R1Z9cukVPifQxtgFK7wLBpAUzM35PfHGlnVPWOlCPh M0lhc89LaMbaKWs6oTkIpPt8l242azunm7JGmvfhzqV3662CFXODMxPgN2ZpzAu1 Oj9PEEHHe4XVMj+ppulyQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduiedtledvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepgfdufeekhfevfeelveeiueevhedvuddukeduvddvlefh ueeuieejtdeuvdevvdeunecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgr nhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmpdhnsggprhgtphhtthhopeefpdhmoh guvgepshhmthhpohhuthdprhgtphhtthhopeifihhmrdhrohhuqhhurghrtheskhgstgdr sggvpdhrtghpthhtohephhhtrghmfhhiughssehgmhgrihhlrdgtohhmpdhrtghpthhtoh epphhgshhqlhdqghgvnhgvrhgrlheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 27 Jan 2026 11:02:17 -0500 (EST) Message-ID: <5043ff13-2f39-4a80-a8f8-6765746b6a89@aklaver.com> Date: Tue, 27 Jan 2026 08:02:17 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Index (primary key) corrupt? To: Wim Rouquart , Greg Sabino Mullane Cc: "pgsql-general@lists.postgresql.org" References: <1bfa0b6b-11a8-458f-a3f3-3f86574abc1d@aklaver.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/27/26 04:18, Wim Rouquart wrote: > Internal > > Again, sorry for the late response. More pressing things tend to get in the way. Bottom line the index exists, it is just not being applied. Questions: 1) What is the restore command being used? 2) From this post: https://www.postgresql.org/message-id/AS2PR05MB10754BFE319E2594C9E076EE2EFFDA%40AS2PR05MB10754.eurprd05.prod.outlook.com What does this: "The steps that show the index is missing is an export of the database while the index is ‘corrupt’, and then importing it. The import fails on foreign keys that are pointing to this index because it is indeed not created." mean? If you REINDEX before the export is the index attached to the table on import? Define 'corrupt'. 3) The field the index points at, id, has: bigint nextval('bcf_work_type_id_seq'::regclass). Is that coming from a bigserial definition or a DEFAULT setting? 4) What happens if you create a test database and restore bcf_work_type by itself, with and without data? > > So the output of these queries before the reindex is: > > db_name_hidden=# select * from pg_index where indexrelid = 'idx_376814_primary'::regclass; > -[ RECORD 1 ]-------+-------- > indexrelid | 2006873 > indrelid | 1998823 > indnatts | 1 > indnkeyatts | 1 > indisunique | t > indnullsnotdistinct | f > indisprimary | t > indisexclusion | f > indimmediate | t > indisclustered | f > indisvalid | t > indcheckxmin | f > indisready | t > indislive | t > indisreplident | f > indkey | 1 > indcollation | 0 > indclass | 3124 > indoption | 0 > indexprs | > indpred | > > db_name_hidden =# \d bcf_work_type > > Table "name_hidden.bcf_work_type" > Column | Type | Collation | Nullable | Default > -----------+--------+-----------+----------+------------------------------------------- > id | bigint | | not null | nextval('bcf_work_type_id_seq'::regclass) > aml_score | bigint | | not null | > Referenced by: > TABLE "bcf_work_type_translation" CONSTRAINT "fk_3cf130ab108734b1" FOREIGN KEY (work_type_id) REFERENCES bcf_work_type(id) ON UPDATE RESTRICT ON DELETE RESTRICT > TABLE "bcf_investment" CONSTRAINT "fk_83580679108734b1" FOREIGN KEY (work_type_id) REFERENCES bcf_work_type(id) ON UPDATE RESTRICT ON DELETE RESTRICT > TABLE "bcf_id_information" CONSTRAINT "fk_f56a0f6b108734b1" FOREIGN KEY (work_type_id) REFERENCES bcf_work_type(id) ON UPDATE RESTRICT ON DELETE RESTRICT > > > After the REINDEX command (REINDEX INDEX idx_376814_primary; ) this becomes: > > db_name_hidden=# select * from pg_index where indexrelid = 'idx_376814_primary'::regclass; > -[ RECORD 1 ]-------+-------- > indexrelid | 2006873 > indrelid | 1998823 > indnatts | 1 > indnkeyatts | 1 > indisunique | t > indnullsnotdistinct | f > indisprimary | t > indisexclusion | f > indimmediate | t > indisclustered | f > indisvalid | t > indcheckxmin | f > indisready | t > indislive | t > indisreplident | f > indkey | 1 > indcollation | 0 > indclass | 3124 > indoption | 0 > indexprs | > indpred | > > db_name_hidden =# \d bcf_work_type > Table "name_hidden.bcf_work_type" > Column | Type | Collation | Nullable | Default > -----------+--------+-----------+----------+------------------------------------------- > id | bigint | | not null | nextval('bcf_work_type_id_seq'::regclass) > aml_score | bigint | | not null | > Indexes: > "idx_376814_primary" PRIMARY KEY, btree (id) > Referenced by: > TABLE "bcf_work_type_translation" CONSTRAINT "fk_3cf130ab108734b1" FOREIGN KEY (work_type_id) REFERENCES bcf_work_type(id) ON UPDATE RESTRICT ON DELETE RESTRICT > TABLE "bcf_investment" CONSTRAINT "fk_83580679108734b1" FOREIGN KEY (work_type_id) REFERENCES bcf_work_type(id) ON UPDATE RESTRICT ON DELETE RESTRICT > TABLE "bcf_id_information" CONSTRAINT "fk_f56a0f6b108734b1" FOREIGN KEY (work_type_id) REFERENCES bcf_work_type(id) ON UPDATE RESTRICT ON DELETE RESTRICT > > So the first result stays the same, in the description of the table now the index shows up... > > > -- Adrian Klaver adrian.klaver@aklaver.com