Measuring execution time

Started by vamsi krishnaover 15 years ago4 messages
#1vamsi krishna
vamsikrishna1902@gmail.com

Hello all

I want to measure the execution time spent running an SQL select query after
the plan generation.

So precisely I want to put my start timer before createQueryDesc() or
ExecutorStart() and end timer after freeQueryDesc() or ExecutorEnd().

Right now I did so in "spi.c", "explain.c", "pquery.c" but they are not the
default execution cases. Can someone tell me which file holds the default
call to ExecutorStart(), because I also want to see the select query result
unlike in the case of "explain" ?

Thanks
Vamsi

#2Robert Haas
robertmhaas@gmail.com
In reply to: vamsi krishna (#1)
Re: Measuring execution time

On Tue, Aug 10, 2010 at 3:46 AM, vamsi krishna
<vamsikrishna1902@gmail.com> wrote:

I want to measure the execution time spent running an SQL select query after
the plan generation.

So precisely I want to put my start timer before createQueryDesc() or
ExecutorStart() and end timer after freeQueryDesc() or ExecutorEnd().

Right now I did so in "spi.c", "explain.c", "pquery.c" but they are not the
default execution cases. Can someone tell me which file holds the default
call to ExecutorStart(), because I also want to see the select query result
unlike in the case of "explain" ?

Well, you should be able to find all the calls to ExecutorStart() by
using grep. But it sounds like you might be better off implementing
this as an executor hook. Or perhaps one of the existing ones
(auto_explain or pg_stat_statements) would give you what you need.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

#3Mark Kirkwood
mark.kirkwood@catalyst.net.nz
In reply to: vamsi krishna (#1)
Re: Measuring execution time

On 10/08/10 19:46, vamsi krishna wrote:

Hello all
I want to measure the execution time spent running an SQL select query
after the plan generation.
So precisely I want to put my start timer before createQueryDesc() or
ExecutorStart() and end timer after freeQueryDesc() or ExecutorEnd().
Right now I did so in "spi.c", "explain.c", "pquery.c" but they are
not the default execution cases. Can someone tell me which file holds
the default call to ExecutorStart(), because I also want to see the
select query result unlike in the case of "explain" ?

See ProcessQuery in src/backend/tcop/query.c

Cheers

Mark

#4Mark Kirkwood
mark.kirkwood@catalyst.net.nz
In reply to: Mark Kirkwood (#3)
Re: Measuring execution time

On 11/08/10 14:42, Mark Kirkwood wrote:

On 10/08/10 19:46, vamsi krishna wrote:

Hello all
I want to measure the execution time spent running an SQL select
query after the plan generation.
So precisely I want to put my start timer before createQueryDesc() or
ExecutorStart() and end timer after freeQueryDesc() or ExecutorEnd().
Right now I did so in "spi.c", "explain.c", "pquery.c" but they are
not the default execution cases. Can someone tell me which file holds
the default call to ExecutorStart(), because I also want to see the
select query result unlike in the case of "explain" ?

See ProcessQuery in src/backend/tcop/query.c

Doh - sorry, I see you have that guy! Have a look at exec_simple_query
in src/backend/tcop/postgres.c, by the time pg_plan_queries returns you
have finished planning. The call to CreateQueryDesc is going to be from
PortalStart in that case. Hopefully this will get you started (you may
need to look at exec_*_message functions too).

Mark