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 1vPOjf-000kM4-23 for pgsql-general@arkaria.postgresql.org; Sat, 29 Nov 2025 17:27:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vPOje-00F9uf-0R for pgsql-general@arkaria.postgresql.org; Sat, 29 Nov 2025 17:27:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vPOjd-00F9uX-01 for pgsql-general@lists.postgresql.org; Sat, 29 Nov 2025 17:27:50 +0000 Received: from fout-a6-smtp.messagingengine.com ([103.168.172.149]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vPOja-002Grs-24 for pgsql-general@postgresql.org; Sat, 29 Nov 2025 17:27:48 +0000 Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id 6CF63EC0975; Sat, 29 Nov 2025 12:27:46 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Sat, 29 Nov 2025 12:27:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= 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=fm3; t=1764437266; x=1764523666; bh=QuCxNWGN7TsQI01v0daxN69speqBjhGcCuJQDOf7Axk=; b= a/RFTQ4Pvt4XtA4rkWjv/wfTycYk5zAetOlDFM186x4XXYeua4sPJcnKQJB6d96G Sm4Rty0HuCtyzM0thKcxPItCtUzQ7TPDL/n04Ldb7a/+dEtq25w2Dr2hXmsVHC10 iY20vNDutK86RW4Fn+ZgNC81/LlNhJgBofAPm7wPjT3aVzpDeYHUnDVdOEihR24B X1Ji5sFudygMmmuPHquvw4KOBDgFDb7BEsf19LUC5vxVQOfty1MKcvVL7ihT6XPU j/RfaPfAbI6MoB544cuigGWZw4feQ/ExOi7Un/s2ckoPCtIkNVqTge98FMVmf2or vLEjlOZUqodfleNnNofH8g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm1; t=1764437266; x=1764523666; bh=Q uCxNWGN7TsQI01v0daxN69speqBjhGcCuJQDOf7Axk=; b=SidU2t60botdfjcBT qc3F/HD4/q67LGZPv/NSSboi8LmF1f8K8TQEyEqrlGJF05SfNsOQL/GZdtU5ufmI phVVolJ5uU0TbKZqoOEkyaCGMQ2Ap2M42fL3pFKEuYJyvTva2eS96lSppqrQLVSe coosnybYGBqgtcaV1D+shtINhbPiBKsX/SrIXZ4cyIM7tvtB9g8Z6Z3SxkMayN3Y yvwJzaMW4TeBWbLBuIc+jJfbncH8rSPYzTnlNKRqEJpPlZnRcuy4wvf6Lm9ykw5E MJciqrGZ0XWsN6WcXn6kk63rYsAxWiPXiOUwTdvEPhXLXdngHqPgA8tjvuM+/Cjg Xr5VQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvheeftdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertd dtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgr vhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepleeikeeigfdtge dvheekueeitdduheeuieelkeffgfevtddvhfdvueeuheektddunecuffhomhgrihhnpehs thgrtghkohhvvghrfhhlohifrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdr tghomhdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh epkhhosghruhhlvghhthdvsehhohhtrdgvvgdprhgtphhtthhopehpghhsqhhlqdhgvghn vghrrghlsehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 29 Nov 2025 12:27:45 -0500 (EST) Message-ID: <3093741e-6a84-43e8-a009-fccff8abe998@aklaver.com> Date: Sat, 29 Nov 2025 09:27:43 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: How to use index in simple select To: Andrus , pgsql-general References: 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 11/28/25 14:57, Andrus wrote: > Hi! > > Table has index on name column: > >         CREATE TABLE firma2.klient >         ( >             kood character(12) primary key, >              nimi character(100), >            ... >         ); > >        CREATE INDEX IF NOT EXISTS klient_nimi_idx >         ON firma2.klient USING btree >         (nimi COLLATE pg_catalog."default" ASC NULLS LAST) >         TABLESPACE pg_default; > > Database settings have default values: > >     enable_indexonlyscan       on >     enable_indexscan           on >     enable_indexonlyscan       on >     enable_indexscan           on > > Query > >     SELECT * FROM firma2.klient WHERE nimi='John'; > > Runs slowly. > >     analyze firma2.klient; >     explain analyze select * from firma2.klient where nimi='John' > > Shows that index is not used: > >     "Seq Scan on klient  (cost=0.00..2287976.20 rows=1 width=4002) > (actual time=12769.987..12769.988 rows=0 loops=1)" >     "  Filter: (nimi = 'John'::bpchar)" >     "  Rows Removed by Filter: 849971" >     "Planning Time: 4.751 ms" >     "Execution Time: 12770.029 ms" > > How to force Postgres to use index? It probably worked long time but > suddenly stopped working today. > Re-started whole windows server but problem persists. > > Using > > PostgreSQL 17.5 on x86_64-windows, compiled by msvc-19.43.34808, 64-bit > > in Windows Server 2022 vers 21H2 > > Andrus. > > > Posted also in > > https://stackoverflow.com/questions/79832965/how-to-use-index-in-simple- > select > > Seems to be already answered: "It looks like reindex table firma2.klient restored index scan. create index concurrently was used when lot of transactions using this table where running" -- Adrian Klaver adrian.klaver@aklaver.com