X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 41DF45280A for ; Mon, 13 Jun 2005 14:57:36 -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 92096-06 for ; Mon, 13 Jun 2005 17:57:31 +0000 (GMT) Received: from tomts16-srv.bellnexxia.net (tomts16-srv.bellnexxia.net [209.226.175.4]) by svr1.postgresql.org (Postfix) with ESMTP id 9215D52814 for ; Mon, 13 Jun 2005 14:57:29 -0300 (ADT) Received: from [192.168.2.99] ([64.228.1.94]) by tomts16-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20050613175729.WEAD27508.tomts16-srv.bellnexxia.net@[192.168.2.99]>; Mon, 13 Jun 2005 13:57:29 -0400 Message-ID: <42ADC90B.4040808@alteeve.com> Date: Mon, 13 Jun 2005 13:57:31 -0400 From: Madison Kelly User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1 X-Accept-Language: en-us, en, ja MIME-Version: 1.0 To: pgsql-performance@postgresql.org Cc: Kevin Grittner , tgl@sss.pgh.pa.us, tobias@nordicbet.com Subject: Re: Index ot being used References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200506/310 X-Sequence-Number: 12947 Kevin Grittner wrote: >>tle-bu=> \d file_info_7_display_idx >> Index "public.file_info_7_display_idx" >> Column | Type >>-----------------+---------------------- >> file_type | character varying(2) >> file_parent_dir | text >> file_name | text >>btree, for table "public.file_info_7" > > > The index is fine, but you need to phrase the query as > > ... ORDER BY file_type, file_parent_dir, file_name; > > (Whether you use ASC or not doesn't matter.) Otherwise the planner > won't make the connection to the sort ordering of the index. > > regards, tom lane With Bruno's help I've gone back and tried just this with no luck. I've re-written the query to include all three items in the 'ORDER BY...' column in the same order but the sort still takes a long time and a sequential scan is being done instead of using the index. For what it's worth, and being somewhat of a n00b, I agree with the idea of a smarter, more flexible planner. I guess the trade off is the added overhead neaded versus the size of the average query. Madison -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Madison Kelly (Digimer) TLE-BU, The Linux Experience; Back Up http://tle-bu.thelinuxexperience.com -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-