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 2EA4E5350F for ; Wed, 20 Apr 2005 12:55:02 -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 53989-10 for ; Wed, 20 Apr 2005 15:54:52 +0000 (GMT) Received: from localhost.net (cust.89.121.adsl.cistron.nl [195.64.89.121]) by svr1.postgresql.org (Postfix) with ESMTP id 603AD53530 for ; Wed, 20 Apr 2005 12:54:49 -0300 (ADT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost.net (Postfix) with ESMTP id 6264283D5E; Wed, 20 Apr 2005 17:54:48 +0200 (CEST) Message-ID: <42667B45.5050101@trust-factory.com> Date: Wed, 20 Apr 2005 17:54:45 +0200 From: Richard van den Berg Organization: Trust Factory User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-perform Subject: Re: When are index scans used over seq scans? References: <426665A0.1080102@trust-factory.com> <26710.1114007961@sss.pgh.pa.us> In-Reply-To: <26710.1114007961@sss.pgh.pa.us> X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200504/508 X-Sequence-Number: 11905 Tom Lane wrote: > The explain shows no such thing. What is the *actual* runtime of > each plan per EXPLAIN ANALYZE, please? I took a simplified version of the problem (the actual query that took 6 hours joins 3 tables). With cpu_tuple_cost = 0.1: Nested Loop (cost=0.00..667700310.42 rows=1035480320 width=97) (actual time=31.468..42629.629 rows=6171334 loops=1) -> Seq Scan on sessions us (cost=0.00..125756.60 rows=924536 width=105) (actual time=31.366..3293.523 rows=924536 loops=1) -> Index Scan using ix_du_ts on duration du (cost=0.00..604.46 rows=1120 width=8) (actual time=0.004..0.011 rows=7 loops=924536) Index Cond: (("outer".starttimetrunc <= du.ts) AND ("outer".finishtimetrunc >= du.ts)) Total runtime: 44337.937 ms The explain analyze for cpu_tuple_cost = 0.01 is running now. If it takes hours, I'll send it to the list tomorrow. -- Richard van den Berg, CISSP ------------------------------------------- Trust Factory B.V. | www.dna-portal.net Bazarstraat 44a | www.trust-factory.com 2518AK The Hague | Phone: +31 70 3620684 The Netherlands | Fax : +31 70 3603009 -------------------------------------------