Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id C2F9D9F9312 for ; Tue, 3 Oct 2006 04:00:40 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 86892-09 for ; Tue, 3 Oct 2006 07:00:17 +0000 (UTC) X-Greylist: delayed 00:10:33.233055 by SQLgrey- Received: from mx06.syd.iprimus.net.au (mx06.syd.iprimus.net.au [210.50.76.235]) by postgresql.org (Postfix) with ESMTP id 9E1689FB305 for ; Tue, 3 Oct 2006 04:00:16 -0300 (ADT) Received: from 233.006.dsl.ade.iprimus.net.au (HELO sdg) ([211.26.53.233]) by mx06.syd.iprimus.net.au with ESMTP; 03 Oct 2006 16:49:35 +1000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AY8CAImjIUU X-IronPort-AV: i="4.09,247,1157292000"; d="scan'208"; a="2444752:sNHT35025382" From: "Tim Truman" To: "'Tom Lane'" Cc: Subject: Re: Forcing the use of particular execution plans Date: Tue, 3 Oct 2006 16:21:01 +0930 Message-ID: <000001c6e6b8$4a696570$0340050a@sdg> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: Acbmoyfk9sV/4ULPR6mpY4aRtPxMCwAEx94g In-Reply-To: <19401.1159849179@sss.pgh.pa.us> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200610/22 X-Sequence-Number: 21151 Thanks Tom The time difference did distract me from the issue. Switching Seq Scan to off reduced the runtime greatly, so I am now adjusting the effective_cache_size, random_page_cost settings to favor indexes over Seq Scans. Regards, Tim -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: Tuesday, 3 October 2006 1:50 PM To: Tim Truman Cc: 'Dave Dutcher'; pgsql-performance@postgresql.org Subject: Re: [PERFORM] Forcing the use of particular execution plans "Tim Truman" writes: > Here is an "explain analyze" for the query that performs slowly, This shows that the planner is exactly correct in thinking that all the runtime is going into the seqscan on transaction: > "Aggregate (cost=88256.32..88256.32 rows=1 width=0) (actual > time=55829.000..55829.000 rows=1 loops=1)" > ... > " -> Seq Scan on "transaction" t > (cost=0.00..87061.04 rows=1630 width=349) (actual time=234.000..55797.000 > rows=200 loops=1)" > " Filter: ((transaction_date >= > '2005-01-01'::date) AND (transaction_date <= '2006-09-25'::date) AND > ((credit_card_no)::text ~~ '4564%549'::text))" Since that component of the plan was identical in your two original plans ("desired" and "undesired") it seems pretty clear that you have not correctly identified what your problem is. regards, tom lane