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.....
char *s;
s = nodeToString(subPlan1);
//then store s into a text file subPlan1.txt on disk.
//and store the sub plan's execution result
....
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?....
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;
}
...
2010/9/3 Tom Lane <tgl@xxxxxxxxxxxxx>
sunpeng <bluevaley@xxxxxxxxx> writes:You can't. The fact that there's nodeToString support for all Plan node
> 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?
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