Thread: Retrieving all possible join trees from PLANNER..

Retrieving all possible join trees from PLANNER..

From
Gayathri TK
Date:
Hello all,

I am using Postgres to do my Masters' thesis work. Given a query, i want 
to know all possible join plan trees for that query.

This information can be got from 
src/backend/optimizer/path/allpaths.c/make_one_rel_by_joins() method.
[ie] more specifically, I need joinitems[levels_needed]

The information i need is a temporary result generated by planner and is 
not passed on to later stages. Hence If i add a command, i wont have 
this infomation by the time ProcessUtility() method is called.

How do i efficiently retrieve this information?

The input to my method is a file containing queries, and output should 
be all possible join plan trees for each query in the file...

Thanks in advance,
Gayathri TK


Re: Retrieving all possible join trees from PLANNER..

From
Tom Lane
Date:
Gayathri TK <gtambar@ncsu.edu> writes:
> How do i efficiently retrieve this information?

You don't, because the planner doesn't actually calculate all possible
join trees --- it wouldn't run in a reasonable amount of time if it
tried.  It only considers trees that are built from subtrees that appear
optimal for their subset of the relations.

If that's enough for your purpose, you could hack the planner to save
aside the info somewhere.  Note that the representation is not a
finished Plan tree, only a Path tree.
        regards, tom lane