Search Postgresql Archives

Re: How to restore a Plan from a stored plan text?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for your help!The motivation is that I try to find the most used sub plan ,and cach the sub plan's execution result and  store sub plan itself on disk. Even the sub plan's connection is closed, the consequent connection with the same sub plan could utilize the stored cached result.
For example.
The first connection comes and according history information we find the most used sub plan, and after execution, i serialize this sub plan node into a text file and stored the sub plan's execution result on disk:
Plan *subPlan1;
....
char       *s;
s = nodeToString(subPlan1);
//then store s into a text file subPlan1.txt on disk.
//and store the sub plan's execution result
....
Then the first connection closed.
Now the second connection comes, if the server generate the same sub plan i could just read the first sub plan's result:
Plan *subPlan2;
....
char *s ;//then read s from the text file subPlan1.txt on disk
Plan *subPlan1 = deserialized(s);
bool equ =  equal(plan1,plan2); //which also can't work for Plan node
if(equ){
   //then return the cached first connection's result;
}
...
Then should I write deserialized(s) codes and another equal(void *, void*) function to support Plan node?


2010/9/3 Tom Lane <tgl@xxxxxxxxxxxxx>
sunpeng <bluevaley@xxxxxxxxx> writes:
> I've used the following codes to translate the PlannedStmt node to a char
> string:
> PlannedStmt * pltl = (PlannedStmt *) linitial(plantree_list);
> Plan *pl = pltl->planTree;
> char       *s;
> s = nodeToString(pl);

>  How to restore from this s to Plan?

You can't.  The fact that there's nodeToString support for all Plan node
types is only intended as a debugging aid --- there's no intention that
it should be possible to serialize and deserialize plans this way.

You didn't say what it is you actually hope to accomplish, but maybe
asking plancache.c to store the plan for you would do.

                       regards, tom lane


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux