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 283173A501F for ; Sun, 23 Jan 2005 22:39:17 +0000 (GMT) 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 88005-03 for ; Sun, 23 Jan 2005 22:39:11 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id EA5163A51CF for ; Sun, 23 Jan 2005 22:39:13 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j0NMdC4Z007192; Sun, 23 Jan 2005 17:39:12 -0500 (EST) To: "Jim C. Nasby" Cc: pgsql-performance@postgresql.org Subject: Re: Odd number of rows expected In-reply-to: <20050123222942.GE67721@decibel.org> References: <20050121203827.GW67721@decibel.org> <26465.1106450280@sss.pgh.pa.us> <20050123222942.GE67721@decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Sun, 23 Jan 2005 16:29:42 -0600" Date: Sun, 23 Jan 2005 17:39:12 -0500 Message-ID: <7191.1106519952@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/427 X-Sequence-Number: 10117 "Jim C. Nasby" writes: > In english, each bucket defines a specific time period, and no two > buckets can over-lap (though there's no constraints defined to actually > prevent that). So reality is that each row in page_log.log will in fact > only match one row in bucket (at least for each value of rrs_id). > Given that, would the optimizer make a better choice if it knew that > (since it means a much smaller result set). Given that the join condition is not an equality, there's no hope of using hash or merge join; so the join itself is about as good as you're gonna get. With a more accurate rows estimate for the join result, it might have decided to use HashAggregate instead of Sort/GroupAggregate, but AFAICS that would not have made a huge difference ... at best maybe 25% of the total query time. > Is there any way to tell the > optimizer this is the case? Nope. This gets back to the old problem of not having any cross-column (cross-table in this case) statistics. regards, tom lane