X-Original-To: pgsql-admin@postgresql.org Received: from mail.virginia.edu (mail.Virginia.EDU [128.143.2.9]) by postgresql.org (Postfix) with SMTP id 2BFB047580B for ; Fri, 21 Mar 2003 11:01:16 -0500 (EST) Received: from smtp.mail.virginia.edu by mail.virginia.edu id aa02332; 21 Mar 2003 11:01 EST Received: from jlk3xpc (d-128-19-222.bootp.Virginia.EDU [128.143.19.222]) by smtp.mail.Virginia.EDU (8.11.6p/8.11.6) with SMTP id h2LG1Dh37528; Fri, 21 Mar 2003 11:01:13 -0500 Message-ID: <007701c2efc3$f5bed260$de138f80@virginia.edu> From: Jodi Kanter To: Joe Conway Cc: Postgres Admin List References: <004101c2efc0$65e6d0a0$de138f80@virginia.edu> <3E7B3365.5090603@joeconway.com> Subject: Re: indexes not being used! Date: Fri, 21 Mar 2003 11:07:23 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Archive-Number: 200303/343 X-Sequence-Number: 7983 I apologize if this is the wrong list. I have posted explain analyzes below. If you have time and can assist I would appreciate it. I will look into the other lists that you mentioned. Thanks Jodi explain analyze select am_pk, smp_fk, am_comments, hybridization_name from arraymeasurement, groupref, grouplink where (groupref.ref_fk=arraymeasurement.am_pk and ((groupref.us_fk=1 and groupref.us_fk=grouplink.us_fk and grouplink.gs_fk=groupref.gs_fk and (groupref.permissions&128)>0) or (groupref.gs_fk=grouplink.gs_fk and grouplink.us_fk=1 and (groupref.permissions&16)>0 ))); NOTICE: QUERY PLAN: Nested Loop (cost=5.88..350.58 rows=1 width=55) (actual time=2.37..73.58 rows=43 loops=1) -> Hash Join (cost=5.88..47.57 rows=42 width=47) (actual time=2.28..12.12 rows=43 loops=1) -> Seq Scan on groupref (cost=0.00..38.83 rows=313 width=16) (actual time=0.05..8.32 rows=275 loops=1) -> Hash (cost=5.50..5.50 rows=150 width=31) (actual time=2.06..2.06 rows=0 loops=1) -> Seq Scan on arraymeasurement (cost=0.00..5.50 rows=150 width=31) (actual time=0.04..1.45 rows=150 loops=1) -> Seq Scan on grouplink (cost=0.00..1.78 rows=78 width=8) (actual time=0.01..0.44 rows=78 loops=43) Total runtime: 74.00 msec explain analyze select ref_fk from groupref, grouplink where ((groupref.us_fk=1 and groupref.us_fk=grouplink.us_fk and grouplink.gs_fk=groupref.gs_fk and (groupref.permissions&128)>0) or (groupref.gs_fk=grouplink.gs_fk and grouplink.us_fk=1 and (groupref.permissions&16)>0 )); NOTICE: QUERY PLAN: Nested Loop (cost=0.00..2303.34 rows=1 width=24) (actual time=0.15..340.53 rows=272 loops=1) -> Seq Scan on groupref (cost=0.00..38.83 rows=313 width=16) (actual time=0.07..9.12 rows=275 loops=1) -> Seq Scan on grouplink (cost=0.00..1.78 rows=78 width=8) (actual time=0.01..0.42 rows=78 loops=275) Total runtime: 341.30 msec explain analyze select ref_fk from groupref, grouplink where (groupref.us_fk=1 and groupref.us_fk=grouplink.us_fk and grouplink.gs_fk=groupref.gs_fk and (groupref.permissions&128)>0); NOTICE: QUERY PLAN: Merge Join (cost=34.96..35.86 rows=32 width=20) (actual time=8.28..12.60 rows=252 loops=1) -> Sort (cost=30.72..30.72 rows=95 width=12) (actual time=7.17..7.59 rows=252 loops=1) -> Seq Scan on groupref (cost=0.00..27.62 rows=95 width=12) (actual time=0.05..4.87 rows=252 loops=1) -> Sort (cost=4.23..4.23 rows=78 width=8) (actual time=1.08..1.56 rows=299 loops=1) -> Seq Scan on grouplink (cost=0.00..1.78 rows=78 width=8) (actual time=0.02..0.46 rows=78 loops=1) Total runtime: 13.30 msec ----- Original Message ----- From: "Joe Conway" To: "Jodi Kanter" Cc: "Postgres Admin List" Sent: Friday, March 21, 2003 10:44 AM Subject: Re: [ADMIN] indexes not being used! > Jodi Kanter wrote: > > We have a query that is causing performance problems. The indexes do > > not appear to be used despite the fact that they exist. I dropped the > > table and recreated from scratch. I reindexed as well and still no > > luck. We vacuum analyze the system often. I will do my best to list > > all that is happening. Any assistance would be greatly appreciated. > > If you can offer some insight as to what the explains are telling me > > that would be so helpful. Is there some documentation somewhere that > > discusses such results? Thanks a lot! Jodi Kanter > > It's hard to tell from what you did post, but if the query returns a > significant portion of the table then a seq scan is faster, and is > properly picked by the optimizer. Please post EXPLAIN ANALYZE results. > > (and actually, this thread probably should be on the SQL or the PERFORM > lists, not this one) > > Joe > > >