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 36F41D76AB for ; Wed, 14 Sep 2005 00:08:40 -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 63432-09 for ; Wed, 14 Sep 2005 03:08:36 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.206]) by svr1.postgresql.org (Postfix) with ESMTP id D7AAFD70C9 for ; Wed, 14 Sep 2005 00:08:34 -0300 (ADT) Received: by rproxy.gmail.com with SMTP id 34so43418rns for ; Tue, 13 Sep 2005 20:08:32 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; b=nVkTPe6uS7TgyhVEMPw5fe6H7397Bxr7KhALPjNcmEOy3YAf+N4GK1IwdiqJrobTst3T6wKIDiTq4fWpZimpJQWJtE2+9SjouesdVPbyJhEgerBAz++9gp0oJ2ucrz1npj0IfseE3/PlnLTf1SC8D6M5qERgY38N8kNAFAY6nQU= Received: by 10.11.119.50 with SMTP id r50mr13065cwc; Tue, 13 Sep 2005 20:08:32 -0700 (PDT) Received: by 10.11.119.38 with HTTP; Tue, 13 Sep 2005 20:08:31 -0700 (PDT) Message-ID: <36e6829205091320085993ceba@mail.gmail.com> Date: Tue, 13 Sep 2005 23:08:31 -0400 From: "Jonah H. Harris" Reply-To: jonah.harris@gmail.com To: pryscila.lista@gmail.com Subject: Re: About method of PostgreSQL's Optimizer Cc: pgsql-hackers@postgresql.org In-Reply-To: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5829_7451872.1126667311980" References: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.549 required=5 tests=[AWL=0.020, HTML_20_30=0.504, HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] X-Spam-Level: X-Archive-Number: 200509/638 X-Sequence-Number: 73035 ------=_Part_5829_7451872.1126667311980 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Pryscila, While I haven't been too involved in the open source PostgreSQL optimizer, = I=20 have done some work on it and optimizers in other database systems. Based on my work, it is my opinion that PostgreSQL, as-well-as other=20 databases which use a cost-based optimizer, prefer a breadth-first algorith= m=20 because one cannot determine the "real" cost of each node at run-time=20 without systematically examining all possibilities through calculation. Thi= s=20 is the opposite of a rule-based optimizer which defines heuristics which ca= n=20 be evaulated by a best-first algorithm such as A*. In a cost-based optimizer, the system must calculate the "cost" of each pat= h=20 based on data that changes during run-time including indexing, cardinality,= =20 tuple size, available memory, CPU usage, disk access times, etc. To a=20 cost-based optimizer, every query is unique and therefore cannot follow a= =20 weighted path in the same fashion. I can certainly see A* being used in a= =20 rule-based optimizer but not in a real-time cost-based optimizer. Perhaps Tom, Bruce, et al have more specifics on PostgreSQL's=20 implementation. -Jonah On 9/13/05, Pryscila B Guttoski wrote: >=20 > Hello all! >=20 > On my master course, I'm studying the PostgreSQL's optimizer. > I don't know if anyone in this list have been participated from the=20 > PostgreSQL's Optimizer development, but maybe someone can help me on this= =20 > question. > PostgreSQL generates all possible plans of executing the query (using an= =20 > almost exhaustive search), then gives a cost to each plan and finally the= =20 > cheapest one is selected for execution. > There are other methods for query optimization, one of them is based on= =20 > plan transformations (for example, using A-Star algorithm) instead of pla= n=20 > constructions used by PostgreSQL.=20 > Does anyone know why this method was choosen? Are there any papers or=20 > researches about it? >=20 > Thank's a lot, > Pryscila. > =20 --=20 Respectfully, Jonah H. Harris, Database Internals Architect EnterpriseDB Corporation http://www.enterprisedb.com/ ------=_Part_5829_7451872.1126667311980 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Pryscila,

While I haven't been too involved in the open source PostgreSQL optimizer, I have done some work on it and optimizers in other database systems.

Based on my work, it is my opinion that PostgreSQL, as-well-as other databases which use a cost-based optimizer, prefer a breadth-first algorithm because one cannot determine the "real" cost of each no= de at run-time without systematically examining all possibilities through calculation.  This is the opposite of a rule-based optimizer which defines heuristics which can be evaulated by a best-first algorithm such as A*.

In a cost-based optimizer, the system must calculate the "cost" o= f each path based on data that changes during run-time including indexing, cardinality, tuple size, available memory, CPU usage, disk access times, etc.  To a cost-based optimizer, every query is unique and therefore cannot follow a weighted path in the same fashion.  I can certainly see A* being used in a rule-based optimizer but not in a real-time cost-based optimizer.

Perhaps Tom, Bruce, et al have more specifics on PostgreSQL's implementatio= n.

-Jonah



On 9/13/05, Pryscila B Guttoski <pryscila.lista@gmail.com> wrote:
Hello all!

On my master course, I'm studying the PostgreSQL's optimizer.
I don't know if anyone in this list have been participated from the PostgreSQL's Optimizer development, but maybe someone can help me on this question.
PostgreSQL generates all possible plans of executing the query (using an almost exhaustive search), then gives a cost to each plan and finally the cheapest one is selected for execution.
There are other methods for query optimization, one of them is based on plan transformations (for example, using A-Star algorithm) instead of plan constructions used by PostgreSQL.
Does anyone know why this method was choosen? Are there any papers or resea= rches about it?

Thank's a lot,
Pryscila.



--
Respectfully,
Jonah H. Harris, Database Internals Architect
EnterpriseDB Corporat= ion
http://www.enterprisedb.com= /
------=_Part_5829_7451872.1126667311980--