X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B1D2CD8EEF for ; Wed, 14 Sep 2005 14:54:55 -0300 (ADT) 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 04131-04 for ; Wed, 14 Sep 2005 17:54:50 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id E3BB1D8EE6 for ; Wed, 14 Sep 2005 14:54:50 -0300 (ADT) 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 j8EHsk2Q006128; Wed, 14 Sep 2005 13:54:47 -0400 (EDT) To: jonah.harris@gmail.com Cc: pryscila.lista@gmail.com, pgsql-hackers@postgresql.org Subject: Re: About method of PostgreSQL's Optimizer In-reply-to: <36e6829205091409361035d32a@mail.gmail.com> References: <36e6829205091320085993ceba@mail.gmail.com> <36e6829205091409361035d32a@mail.gmail.com> Comments: In-reply-to "Jonah H. Harris" message dated "Wed, 14 Sep 2005 12:36:37 -0400" Date: Wed, 14 Sep 2005 13:54:46 -0400 Message-ID: <6127.1126720486@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200509/668 X-Sequence-Number: 73065 "Jonah H. Harris" writes: > As for using both in the same optimizer, I could only see an algorithm such > as a customized-A* being used to planning *some* large queries. The reason I > say this is because the cost calculation, which would still need to be > breadth-first, could calculate and cache the cost of most nodes thereby > allowing you to possibly perform transformations at the tail of calculation. We do already have two different plan search algorithms: the strict bottom-up dynamic programming approach (System R style) and the GEQO optimizer, which we switch to when there are too many joins needed to allow exhaustive search. The GEQO code still depends on the normal plan cost estimation code, but it doesn't consider every possible plan. I've never been very happy with the GEQO code: the random component of the algorithm means you get unpredictable (and sometimes awful) plans, and the particular variant that we are using is really designed to solve traveling-salesman problems. It's at best a poor fit to the join planning problem. So it seems interesting to me to think about replacing GEQO with a rule-based optimizer for large join search spaces. There are previous discussions about this in the archives, I believe. regards, tom lane