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 1l6xxh-00020y-4J for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Feb 2021 15:51:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l6xxf-0007MV-Fk for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Feb 2021 15:51:27 +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 1l6xxf-0007MO-9g for pgsql-bugs@lists.postgresql.org; Tue, 02 Feb 2021 15:51:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l6xxc-0000N3-Ps for pgsql-bugs@lists.postgresql.org; Tue, 02 Feb 2021 15:51:26 +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 112FpNjl3716069; Tue, 2 Feb 2021 10:51:23 -0500 From: Tom Lane To: kokdemir@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16849: index and table data inconsistency In-reply-to: <16849-17287340f8774148@postgresql.org> References: <16849-17287340f8774148@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Tue, 02 Feb 2021 10:33:17 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3716067.1612281083.1@sss.pgh.pa.us> Date: Tue, 02 Feb 2021 10:51:23 -0500 Message-ID: <3716068.1612281083@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > I have data in a varchar field like '092', '00000000169', '0000001' and so > on. There is a btree index on this field. my searches are similar to below > ones. > select searched_field from searched_table where searched_field = '092'; > When I search data, it uses the given index and returns no value. But when I > disable index scan, it does a sequential scan and return data. > We have witnessed this case in one index in our production(11.7) and > staging(12.2) environments on same index. Then we dropped the index and > recreate it. The problem is solved. But, to me, index and data must be > consistent. Most likely you got bit by an operating-system locale change causing a change in sort order and thereby making the index self-inconsistent. See https://wiki.postgresql.org/wiki/Locale_data_changes There's work afoot to have Postgres automatically notice when the OS changes underneath it, but that's not done yet. regards, tom lane