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 9ACF3539E1 for ; Thu, 21 Apr 2005 13:16:57 -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 22648-10 for ; Thu, 21 Apr 2005 16:16: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 588F25391C for ; Thu, 21 Apr 2005 13:16:51 -0300 (ADT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost.net (Postfix) with ESMTP id DE91083D6E; Thu, 21 Apr 2005 18:16:48 +0200 (CEST) Message-ID: <4267D1ED.7010606@trust-factory.com> Date: Thu, 21 Apr 2005 18:16: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> <4267612C.10803@trust-factory.com> <15074.1114093502@sss.pgh.pa.us> In-Reply-To: <15074.1114093502@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/571 X-Sequence-Number: 11968 Tom Lane wrote: > which is almost 80% of the entire runtime. Which is enormous. > What are those column datatypes exactly? Table "richard.sessions" Column | Type | Modifiers ------------------------+-----------------------------+----------- [unrelated columns removed] starttimetrunc | timestamp without time zone | finishtimetrunc | timestamp without time zone | Indexes: "rb_us_st_ft_idx" btree (starttimetrunc, finishtimetrunc) "rb_us_st_ft_idx2" btree (finishtimetrunc, starttimetrunc) Check constraints: "date_check" CHECK (finishtimetrunc >= starttimetrunc) Table "richard.duration" Column | Type | Modifiers --------+-----------------------------+----------- ts | timestamp without time zone | > Perhaps you are incurring a datatype conversion cost? Not that I can tell. > It seems more likely that the cpu_operator_cost is underestimated, As you perdicted, increasing cpu_operator_cost from 0.0025 to 0.025 also causes the planner to use the index on duration. > which leads me to question what exactly is happening in those > comparisons. Your guess is as good as mine (actually, yours is much better). I can put together a reproducable test case if you like.. -- 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 ------------------------------------------- Have you visited our new DNA Portal? -------------------------------------------