Re: How to restore a Plan from a stored plan text?
От | sunpeng |
---|---|
Тема | Re: How to restore a Plan from a stored plan text? |
Дата | |
Msg-id | AANLkTi=K-D4xM04XsmB-fDaaDyX-tEsV9n6JhWrN=10w@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: How to restore a Plan from a stored plan text? (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: How to restore a Plan from a stored plan text?
|
Список | pgsql-general |
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:
Now the second connection comes, if the server generate the same sub plan i could just read the first sub plan's 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.....
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@sss.pgh.pa.us>
sunpeng <bluevaley@gmail.com> 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
В списке pgsql-general по дате отправления: