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 86EC753D06 for ; Thu, 21 Apr 2005 05:16:00 -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 00620-08 for ; Thu, 21 Apr 2005 08:15:50 +0000 (GMT) Received: from localhost.net (cust.89.121.adsl.cistron.nl [195.64.89.121]) by svr1.postgresql.org (Postfix) with ESMTP id 2E2EA53CE7 for ; Thu, 21 Apr 2005 05:15:47 -0300 (ADT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost.net (Postfix) with ESMTP id BC91C83D6E; Thu, 21 Apr 2005 10:15:47 +0200 (CEST) Message-ID: <4267612C.10803@trust-factory.com> Date: Thu, 21 Apr 2005 10:15:40 +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=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200504/550 X-Sequence-Number: 11947 Tom Lane wrote: > The explain shows no such thing. What is the *actual* runtime of > each plan per EXPLAIN ANALYZE, please? Ok, it took 3.5 hours to complete. :-/ This is with the default cpu_tuple_cost = 0.01: Nested Loop (cost=252.80..233010147.16 rows=1035480320 width=98) (actual time=0.369..12672213.137 rows=6171334 loops=1) Join Filter: (("outer".starttimetrunc <= "inner".ts) AND ("outer".finishtimetrunc >= "inner".ts)) -> Seq Scan on sessions us (cost=0.00..26822.36 rows=924536 width=106) (actual time=0.039..5447.349 rows=924536 loops=1) -> Materialize (cost=252.80..353.60 rows=10080 width=8) (actual time=0.000..2.770 rows=10080 loops=924536) -> Seq Scan on duration du (cost=0.00..252.80 rows=10080 width=8) (actual time=0.019..13.397 rows=10080 loops=1) Total runtime: 12674486.670 ms Once again with cpu_tuple_cost = 0.1: Nested Loop (cost=0.00..667684584.42 rows=1035480320 width=98) (actual time=42.892..39877.928 rows=6171334 loops=1) -> Seq Scan on sessions us (cost=0.00..110030.60 rows=924536 width=106) (actual time=0.020..917.803 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: 41635.468 ms (5 rows) -- 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 -------------------------------------------