From: | sunpeng <bluevaley(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to restore a Plan from a stored plan text? |
Date: | 2010-09-04 05:26:58 |
Message-ID: | AANLkTi=K-D4xM04XsmB-fDaaDyX-tEsV9n6JhWrN=10w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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:
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(at)sss(dot)pgh(dot)pa(dot)us>
> sunpeng <bluevaley(at)gmail(dot)com> 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
>
From | Date | Subject | |
---|---|---|---|
Next Message | sunpeng | 2010-09-04 05:46:44 | How to let the created table visible to current process when using SPI_execute("create table ...")? |
Previous Message | Tom Lane | 2010-09-04 04:43:16 | Re: How to restore a Plan from a stored plan text? |