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 60479528D1 for ; Sun, 12 Jun 2005 14:38:15 -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 29060-08 for ; Sun, 12 Jun 2005 17:38:08 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.197.194]) by svr1.postgresql.org (Postfix) with SMTP id 3EAC7528BF for ; Sun, 12 Jun 2005 14:38:07 -0300 (ADT) Received: (qmail 29079 invoked by uid 500); 12 Jun 2005 17:37:32 -0000 Date: Sun, 12 Jun 2005 12:37:32 -0500 From: Bruno Wolff III To: Madison Kelly Cc: Tobias Brox , pgsql-performance@postgresql.org Subject: Re: Index ot being used Message-ID: <20050612173732.GA28838@wolff.to> Mail-Followup-To: Bruno Wolff III , Madison Kelly , Tobias Brox , pgsql-performance@postgresql.org References: <1825.216.209.137.1.1118419819.squirrel@mail.alteeve.com> <20050610155535.GO8451@tobias.nordicbet.com> <42AC42CB.8050703@alteeve.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42AC42CB.8050703@alteeve.com> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/262 X-Sequence-Number: 12899 On Sun, Jun 12, 2005 at 10:12:27 -0400, Madison Kelly wrote: > Indexes: > "file_info_7_display_idx" btree (file_type, file_parent_dir, file_name) > Here is my full query: > > tle-bu=> EXPLAIN ANALYZE SELECT file_name, file_parent_dir, file_type > FROM file_info_7 WHERE file_type='d' ORDER BY file_parent_dir ASC, > file_name ASC; > QUERY PLAN > ----------------------------------------------------------------------------------------------------------------------------- This is a case where postgres's planner can't make a deduction needed for it to realize that the index can be used. Try rewriting the query as: SELECT file_name, file_parent_dir, file_type FROM file_info_7 WHERE file_type='d' ORDER BY file_type ASC, file_parent_dir ASC, file_name ASC;