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 23BCF5349D for ; Wed, 6 Apr 2005 23:35:20 +0100 (BST) 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 30079-01 for ; Wed, 6 Apr 2005 22:35: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 667745296D for ; Wed, 6 Apr 2005 23:35:11 +0100 (BST) 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 j36MZAwj006595; Wed, 6 Apr 2005 18:35:10 -0400 (EDT) To: "Jim C. Nasby" Cc: Arjen van der Meijden , pgsql-hackers@postgreSQL.org, pgsql-performance@postgreSQL.org Subject: Re: [HACKERS] Recognizing range constraints (was Re: Plan for relatively simple query seems to be very inefficient) In-reply-to: <20050406222536.GL93835@decibel.org> References: <425413D3.5030304@vulcanus.its.tudelft.nl> <28552.1112809334@sss.pgh.pa.us> <425423A9.9000504@vulcanus.its.tudelft.nl> <5999.1112820690@sss.pgh.pa.us> <6326.1112825377@sss.pgh.pa.us> <20050406222536.GL93835@decibel.org> Comments: In-reply-to "Jim C. Nasby" message dated "Wed, 06 Apr 2005 17:25:36 -0500" Date: Wed, 06 Apr 2005 18:35:10 -0400 Message-ID: <6594.1112826910@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/128 X-Sequence-Number: 11525 "Jim C. Nasby" writes: > On Wed, Apr 06, 2005 at 06:09:37PM -0400, Tom Lane wrote: >> Can anyone suggest a more general rule? Do we need for example to >> consider whether the relation membership is the same in two clauses >> that might be opposite sides of a range restriction? It seems like >> >> a.x > b.y AND a.x < b.z > In a case like this, you could actually look at the data in b and see > what the average range size is. Not with the current statistics --- you'd need some kind of cross-column statistics involving both y and z. (That is, I doubt it would be helpful to estimate the average range width by taking the difference of independently-calculated mean values of y and z ...) But yeah, in principle it would be possible to make a non-default estimate. regards, tom lane