Thread: Having trouble startin off with the code..

Having trouble startin off with the code..

From
Gayathri TK
Date:
Hi all,

I am new user of postgres..  I am currently working on a project
for my advisor and the project is to implement an algorithm for 
materialiazed view design as explained in this paper 
[http://www.vldb.org/conf/1997/P136.PDF - MVPP Generation part and sec 
4.1 for selecting views as such.. ]

This project is a part of the bigger project and hence i want to 
implement the algorithm rather than using already existing functionality 
in postgres..  I have read various documents about postgres but have not 
looked into the source code.. hence currently, i am [only] familiar with 
higher level details and not the data structures..

As i understand from the paper, the only reason i am using postgres is 
to be able to get ALL POSSIBLE JOIN PLANS from optimizer.. other than 
this my algorithm is self sufficient.. Hence i would like to know what 
is the best way to go about implementing the algorithm.. Here are my 
thougths..

1. I can implement it as a "command" in postgres... I donno the exact 
steps for this, but understand that it requires modifying a LOT of files ..

2. I can write my own standalone code, if i could invoke postgres with 
my query from the code and be able to access optimizer to get list of 
all possible join plans ? is it possible to do this? How do i invoke 
postgres from C code?

3. Is there any other way of doing this?

I would also like to know your rough guess on the time i would take to 
do the interfacing with postgres? [ i am above average C programmer.. 
pretty good in pointers.. but this is my first exposure to open source 
database..]

I REALLY need help on this and would appreciate if you could help me 
figure this out..

Thanks in advance,
Gayathri TK


Re: Having trouble startin off with the code..

From
Martijn van Oosterhout
Date:
On Thu, Oct 27, 2005 at 12:04:11AM -0400, Gayathri TK wrote:
> Hi all,
>
> I am new user of postgres..  I am currently working on a project
> for my advisor and the project is to implement an algorithm for
> materialiazed view design as explained in this paper
> [http://www.vldb.org/conf/1997/P136.PDF - MVPP Generation part and sec
> 4.1 for selecting views as such.. ]

<snip>

> As i understand from the paper, the only reason i am using postgres is
> to be able to get ALL POSSIBLE JOIN PLANS from optimizer.. other than
> this my algorithm is self sufficient.. Hence i would like to know what
> is the best way to go about implementing the algorithm.. Here are my
> thougths..
>
> 1. I can implement it as a "command" in postgres... I donno the exact
> steps for this, but understand that it requires modifying a LOT of files ..
>
> 2. I can write my own standalone code, if i could invoke postgres with
> my query from the code and be able to access optimizer to get list of
> all possible join plans ? is it possible to do this? How do i invoke
> postgres from C code?

Just a hint, by *far* the easier method is to write it as a standalone
module first, like myfunc(string). The reason is that a function is
loaded seperately you during development. You change the code, compile,
test, etc...

If you build it into the main system you have to change a lot more code
(you noticed that) and you have to recompile everything just to test.

Once you've got your external function doing what you want, you can
start looking to integrate the parser and other node.

> I would also like to know your rough guess on the time i would take to
> do the interfacing with postgres? [ i am above average C programmer..
> pretty good in pointers.. but this is my first exposure to open source
> database..]

The code you're looking for is probably in src/backend/optimizer/path
or plan. *Read* the README files scattered around the directories, they
explain a lot. Also, following the execution path through the different
modules is clarifying. There are lot of comments explaining what's
going on. You won't understand them the first time round, but give it
time...

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.