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 1vQ0rO-005jMx-0Z for pgsql-general@arkaria.postgresql.org; Mon, 01 Dec 2025 10:10:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQ0rM-001sgZ-2U for pgsql-general@arkaria.postgresql.org; Mon, 01 Dec 2025 10:10:21 +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 1vQ0rM-001sgR-1H for pgsql-general@lists.postgresql.org; Mon, 01 Dec 2025 10:10:20 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQ0rJ-002YQP-1d for pgsql-general@postgresql.org; Mon, 01 Dec 2025 10:10:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version :References:Reply-To:Message-ID:Subject:Cc:To:Sender:From:Date:Content-ID: Content-Description; bh=jN9d3ZxHBU+JXg/nCOazczZPKnpUACy3I6GvavWFg04=; b=HpGE0 luaOmGL1q3kn6Ev/YtZDN+UhVE6cyV+BnM9ULLMVX+Zj3X5qO++AEgBheM81Uh44Drhkif79RqW+F l4H8sNfkWhZPqXB2k5EZDAAKg0EVwUEccphj1tO9CUHrMGvDD8OxhrL0ynU1Wlk90Nvl422KzXrP0 LQbQzijIghIQ=; Received: from depesz by depesz.com with local (Exim 4.96) (envelope-from ) id 1vQ0rG-000pJy-2w; Mon, 01 Dec 2025 11:10:14 +0100 Date: Mon, 1 Dec 2025 11:10:14 +0100 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Andrus Cc: pgsql-general Subject: Re: How to use index in simple select Message-ID: Reply-To: depesz@depesz.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Nov 29, 2025 at 12:57:46AM +0200, 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; You got your help, hopefully, but please, please, please, for the love of anything that you care about: 1. read, and apply: https://wiki.postgresql.org/wiki/Don't_Do_This -> specifically the part about char(n) datatype since wiki seems to be having problems for some time now, here is archived version: https://web.archive.org/web/20251002222437/https://wiki.postgresql.org/wiki/Don't_Do_This 2. Why did you specify so many things in your index? Generally you should use CONCURRENTLY (which you didn't), but you don't need tablespace definition, nor collate, nor ordering, nor nulls last. Unless you know, for a fact, with proof, that you know what you're doing and it makes sense. CREATE index concurrently klient_nimi_idx on firma2.klient (nimi); should be enough. Best regards, depesz