| From: | Vaibhav Kaushal <vaibhavkaushal123(at)gmail(dot)com> |
|---|---|
| To: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: How to look at the Expression Trees |
| Date: | 2011-03-21 12:37:12 |
| Message-ID: | AANLkTikbdV6T3MrcgGz=RrYMPQ3Jm4gtrrkOLMYUN8U5@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Mar 21, 2011 at 5:47 PM, Heikki Linnakangas <
heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
>
> Yes. There's actually two "trees" involved. The planner produces a tree of
> Expr nodes, and ExecInitExpr prepares a tree of ExprState nodes that mirrors
> the first tree. The ExprStates contain run-time state needed to execute the
> Expr tree.
>
>
> Yes I am seeing that in the code.
> 5. The most common nodes in the expression trees are the ExecEvalVar,
>> ExecEvalConst and ExecEvalParam.
>>
>
> Well, that's obviously going to depend on the query.
>
> Indeed yes, it does, but still for most cases the ExecEvalVar or
ExecEvalScalarVar is seen a lot of times (I am trying only simple queries
which take most data from disk) which is why i said that. Anyways you are
right there.
>
> I might be wrong somewhere (especially most people would be able to say
>> a lot about the 5th point). But if the above were to be correct then how
>> and why are the ExecMakeFunctionResultNoSets, ExecEvalRelabelType,
>> ExecEvalFuncArgs and the likes are used?
>>
>
> ExecMakeFunctionResultNoSets is used to evaluate function calls. The first
> function call invocation always uses ExecMakeFunctionResult, but if
> ExecMakeFunctionResult sees on that first invocation that it was not a
> set-returning-function, it changes the evaluator function for subsequent
> invocations to ExecMakeFunctionResultNoSets. ExecMakeFunctionResultNoSets
> does the same thing as ExecMakeFunctionResult, but skips the checks for
> set-returning functions, making the evaluation a bit faster.
>
> ExecEvalFuncArgs is used by ExecMakeFunctionResult to evaluate the function
> arguments.
>
> ExecEvalRelabelType is used to evaluate RelabelType nodes. RelabelType
> doesn't really do anything, it's just a placeholder when a type is cast to
> another, and the source and target types are binary compatible.
>
> did not know the last fact.
>
> I wanted to see how the expression tree gets into form before it gets
>> into the ExecQual for parse by ExecEvalExpr function. Is there a way to
>> see the Expression Tree so that I get a better idea about what is
>> happening?
>>
>
> set debug_print_plan=on
>
> I am already using the postgresql server with -d 4 option and it shows a
lot of things. But I am not able to see the Expression State trees. OK. I
know that the output DOES show the 'expr' entries. But if those are what
make the Expression _tree_ then I am not able to understand them. A little
help on that would be generous.
> --
> Heikki Linnakangas
> EnterpriseDB http://www.enterprisedb.com
>
Regards,
Vaibhav
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Heikki Linnakangas | 2011-03-21 13:24:15 | Re: How to look at the Expression Trees |
| Previous Message | Heikki Linnakangas | 2011-03-21 12:17:38 | Re: How to look at the Expression Trees |