Re: Plan structure - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: Plan structure
Date
Msg-id 20051015180913.GE14113@svana.org
Whole thread Raw
In response to Plan structure  (Anuj Tripathi <anujt@it.iitb.ac.in>)
Responses Re: Plan structure
List pgsql-hackers
On Sat, Oct 15, 2005 at 10:19:44PM +0530, Anuj Tripathi wrote:
> Hi
> I am trying to  add a query progress indicator in postgres.Being a
> novice to the code I need help on few topics.
> 1.Where can we keep such a progress indicator code ?
> 2.What is the exact structure of plan returned by the planner ?
> 3.Does the planner return the estimates calculated while deciding   the
> plan ?
> 4.If not , then from where can we obtain those estimates ( estimates
> taken to decide the best plan ) ?

I suggest you look at executor/execProcnode.c. Every time a node in the
execution tree is executed, it will call ExecProcNode. What you are
trying to do is related to the EXPLAIN ANALYZE instrumentation
(InstrStartNode/InstrStopNode).

The comment at the top of that file is also a good explanation of how
the executor works. The executor deals with PlanState structures
(defined in include/nodes/execnodes.h), one of whose members (plan) is
a pointer to the original plan node. The Plan structure (defined in
include/nodes/plannodes.h) contains the fields you're looking for
(startup_cost, total_cost and plan_rows).

Read the comments in those files, they are generally very enlightening
as to how it all works. Also, there are various README files in the
directories which also provide additional info.

Hopefully this answers your questions.
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

pgsql-hackers by date:

Previous
From: Anuj Tripathi
Date:
Subject: Plan structure
Next
From: Tom Lane
Date:
Subject: Re: Plan structure