X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 803CBD9895 for ; Tue, 27 Sep 2005 07:50:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98995-05 for ; Tue, 27 Sep 2005 10:50:27 +0000 (GMT) Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by svr1.postgresql.org (Postfix) with ESMTP id 87B88D98C1 for ; Tue, 27 Sep 2005 07:50:27 -0300 (ADT) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 0EBDC41592C; Tue, 27 Sep 2005 11:50:22 +0100 (BST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 402CC15F1E; Tue, 27 Sep 2005 11:48:19 +0100 (BST) Received: from mainbox.archonet.com ([127.0.0.1]) by localhost (mainbox [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12192-01; Tue, 27 Sep 2005 11:48:16 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id BA55715F1D; Tue, 27 Sep 2005 11:48:15 +0100 (BST) Message-ID: <4339236F.7070403@archonet.com> Date: Tue, 27 Sep 2005 11:48:15 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?windows-1251?Q?=C0=ED=E4=F0=E5=E9_=D0=E5=EF=EA=EE?= Cc: pgsql-performance@postgresql.org Subject: Re: Index not used on group by References: <144520928.20050927121431@sart.must-ipra.com> In-Reply-To: <144520928.20050927121431@sart.must-ipra.com> Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.057 required=5 tests=[AWL=0.007, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200509/370 X-Sequence-Number: 14678 Andrey Repko wrote: > > I have table ma_data, that contain above 300000 rows. > This table has primary key id, and field alias_id. > I create index (btree)on this field. > Set statistic: > > ALTER TABLE "public"."ma_data" > ALTER COLUMN "alias_id" SET STATISTICS 998; > > So, when I do something like > SELECT alias_id FROM ma_data GROUP BY alias_id Why are you using GROUP BY without any aggregate functions? What happens if you use something like SELECT DISTINCT alias_id FROM ma_data; -- Richard Huxton Archonet Ltd