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 3FD8352822 for ; Mon, 13 Jun 2005 01:29:18 -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 00733-09 for ; Mon, 13 Jun 2005 04:29:09 +0000 (GMT) Received: from tomts36-srv.bellnexxia.net (tomts36.bellnexxia.net [209.226.175.93]) by svr1.postgresql.org (Postfix) with ESMTP id D27CA52814 for ; Mon, 13 Jun 2005 01:29:08 -0300 (ADT) Received: from [192.168.2.99] ([206.172.173.123]) by tomts36-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20050613042907.IZWM16985.tomts36-srv.bellnexxia.net@[192.168.2.99]>; Mon, 13 Jun 2005 00:29:07 -0400 Message-ID: <42AD0B94.9090508@alteeve.com> Date: Mon, 13 Jun 2005 00:29:08 -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: Bruno Wolff III , Tom Lane Subject: Re: Index ot being used References: <1825.216.209.137.1.1118419819.squirrel@mail.alteeve.com> <20050610155535.GO8451@tobias.nordicbet.com> <42AC42CB.8050703@alteeve.com> <24636.1118591783@sss.pgh.pa.us> <42ACBC95.9020404@alteeve.com> <20050613030001.GB17491@wolff.to> <20050613031317.GA18988@wolff.to> <42AD008D.4080600@alteeve.com> <20050613035346.GA20703@wolff.to> In-Reply-To: <20050613035346.GA20703@wolff.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/273 X-Sequence-Number: 12910 Bruno Wolff III wrote: > On Sun, Jun 12, 2005 at 23:42:05 -0400, > Madison Kelly wrote: > >>As you probably saw in my last reply, I went back to the old index and >>tried the query you and Tom Lane recommended. Should this not have >>caught the index? > > > Probably, but there might be some other reason the planner thought it > was better to not use it. Using indexes is not always faster. > > It would help to see your latest definition of the table and indexes, > the exact query you used and explain analyze output. > Okay, here's what I have at the moment: tle-bu=> \d file_info_7 Table "public.file_info_7" Column | Type | Modifiers ----------------------+----------------------+----------------------------------------- file_group_name | text | file_group_uid | bigint | not null file_mod_time | bigint | not null file_name | text | not null file_parent_dir | text | not null file_perm | text | not null file_size | bigint | not null file_type | character varying(2) | not null default 'f'::character varying file_user_name | text | file_user_uid | bigint | not null file_backup | boolean | not null default true file_display | boolean | not null default false file_restore_display | boolean | not null default false file_restore | boolean | not null default false Indexes: "file_info_7_display_idx" btree (file_parent_dir, file_name) tle-bu=> \d file_info_7_display_idx Index "public.file_info_7_display_idx" Column | Type -----------------+------ file_parent_dir | text file_name | text btree, for table "public.file_info_7" tle-bu=> EXPLAIN ANALYZE SELECT file_name, file_parent_dir, file_display FROM file_info_7 WHERE file_type='d' ORDER BY file_parent_dir ASC, file_name ASC; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------- Sort (cost=15091.53..15165.29 rows=29502 width=114) (actual time=12834.933..12955.136 rows=25795 loops=1) Sort Key: file_parent_dir, file_name -> Seq Scan on file_info_7 (cost=0.00..11762.44 rows=29502 width=114) (actual time=0.244..2533.388 rows=25795 loops=1) Filter: ((file_type)::text = 'd'::text) Total runtime: 13042.421 ms (5 rows) Since my last post I went back to a query closer to what I actually want. What is most important to me is that 'file_parent_dir, file_name, file_display' are returned and that the results are sorted by 'file_parent_dir, file_name' and the results are restricted to where 'file_info='d''. Basically what I am trying to do is display a directory tree in a file browser. I had this working before but it was far, far too slow once the number of directories to display got much higher than 1,000. That is what 'file_display' is, by the way. Again, thank you! Madison -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Madison Kelly (Digimer) TLE-BU, The Linux Experience; Back Up http://tle-bu.thelinuxexperience.com -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-