Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id EC86164FCF6 for ; Thu, 7 Aug 2008 18:01:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 42556-02 for ; Thu, 7 Aug 2008 18:01:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id AB2A9650341 for ; Thu, 7 Aug 2008 18:01:50 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m77L1lql027579; Thu, 7 Aug 2008 17:01:47 -0400 (EDT) To: Giorgio Valoti cc: pgsql-performance@postgresql.org Subject: Re: Query Plan choice with timestamps In-reply-to: References: <321506D5-4400-470C-909E-C7700D49A540@mac.com> <12707.1218124259@sss.pgh.pa.us> Comments: In-reply-to Giorgio Valoti message dated "Thu, 07 Aug 2008 20:37:09 +0200" Date: Thu, 07 Aug 2008 17:01:47 -0400 Message-ID: <27578.1218142907@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/52 X-Sequence-Number: 30933 Giorgio Valoti writes: > On 07/ago/08, at 17:50, Tom Lane wrote: >> These numbers seem pretty bogus: there is hardly any scenario in >> which a >> full-table indexscan should be costed as significantly cheaper than a >> seqscan. Have you put in silly values for random_page_cost? > No, I looked at it more closely and realized that the cost discrepancy is from the evaluation of the function: having to evaluate a SQL or plpgsql function 247736 times more than explains the cost estimate differential compared to a query that involves no function call. Some experiments here suggest that it hardly matters whether the query uses indexscan or seqscan because the time is dominated by the function calls anyway. regards, tom lane