X-Original-To: pgsql-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5591F475E14; Tue, 6 May 2003 00:25:30 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 6E4F1475CBC; Tue, 6 May 2003 00:25:29 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h464PXU6022293; Tue, 6 May 2003 00:25:33 -0400 (EDT) To: josh@agliodbs.com Cc: pgsql-performance , pgsql-hackers@postgresql.org Subject: Re: Hypothetical suggestions for planner, indexing improvement In-reply-to: <200305051219.58955.josh@agliodbs.com> References: <200305051219.58955.josh@agliodbs.com> Comments: In-reply-to Josh Berkus message dated "Mon, 05 May 2003 12:19:58 -0700" Date: Tue, 06 May 2003 00:25:33 -0400 Message-ID: <22292.1052195133@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-29.3 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/93 X-Sequence-Number: 38600 Josh Berkus writes: > THE IDEA: The planner should keep statistics on the correlation of foreign > keys and apply them to the expected row counts for EXISTS clause limitations, > and possibly for other query types as well. It's a thought. Keeping complete cross-column correlation stats (for every combination of columns in the DB) is obviously out of the question. If you're gonna do it you need a heuristic to tell you which combinations of columns are worth keeping track of --- and foreign-key relationships seem like a reasonable guide to the interesting combinations. I'm not sure about the long-term usefulness of optimizing EXISTS per se. Seems to me that a lot of the present uses of EXISTS are workarounds for Postgres' historic mistreatment of IN ... which we've attacked more directly for 7.4. But cross-column correlations are certainly useful for estimating join sizes in general. regards, tom lane