Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id D79549FBCC0 for ; Wed, 9 May 2007 11:11:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 35480-05 for ; Wed, 9 May 2007 11:11:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id C32E69FBDF4 for ; Wed, 9 May 2007 11:11:40 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l49EBaII026360; Wed, 9 May 2007 10:11:36 -0400 (EDT) To: Peter Eisentraut cc: pgsql-performance@postgresql.org Subject: Re: Nested loops overpriced In-reply-to: <200705091358.25748.peter_e@gmx.net> References: <200705081722.16731.peter_e@gmx.net> <1987.1178639593@sss.pgh.pa.us> <200705091358.25748.peter_e@gmx.net> Comments: In-reply-to Peter Eisentraut message dated "Wed, 09 May 2007 13:58:25 +0200" Date: Wed, 09 May 2007 10:11:36 -0400 Message-ID: <26359.1178719896@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/190 X-Sequence-Number: 24580 Peter Eisentraut writes: > Am Dienstag, 8. Mai 2007 17:53 schrieb Tom Lane: >> Hmm, I'd have expected it to discount the repeated indexscans a lot more >> than it seems to be doing for you. As an example in the regression >> database, note what happens to the inner indexscan cost estimate when >> the number of outer tuples grows: > I can reproduce your results in the regression test database. 8.2.1 and 8.2.4 > behave the same. Well, there's something funny going on here. You've got for instance -> Index Scan using email_pkey on email (cost=0.00..3.85 rows=1 width=8) (actual time=0.005..0.005 rows=0 loops=280990) Index Cond: (email.email_id = eh_from.email_id) Filter: (("time" >= '2007-05-05 17:01:59'::timestamp without time zone) AND ("time" < '2007-05-05 18:01:59'::timestamp without time zone)) on the inside of a nestloop whose outer side is predicted to return 107156 rows. That should've been discounted to *way* less than 3.85 cost units per iteration. Are you using any nondefault planner settings? How big are these tables, anyway? regards, tom lane