Re: Plan structure

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Anuj Tripathi <anujt(at)it(dot)iitb(dot)ac(dot)in>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Plan structure
Date: 2005-10-15 18:09:20
Message-ID: 20051015180913.GE14113@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-10-15 19:16:02 Re: Plan structure
Previous Message Anuj Tripathi 2005-10-15 16:49:44 Plan structure