public inbox for [email protected]  
help / color / mirror / Atom feed
Finding execution time for a query
2+ messages / 2 participants
[nested] [flat]

* Finding execution time for a query
@ 2025-03-13 09:51  Prasanna Thirugnanasambandam <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Prasanna Thirugnanasambandam @ 2025-03-13 09:51 UTC (permalink / raw)
  To: [email protected]

Hello all,

How do I find the execution time of a query?
I tried these methods:
I used

pgbench - pgbench -n -t 1 -f ./query.sql <database name>

and got:

    latency average = 9.787 ms <- should i take this as the execution time?
    initial connection time = 12.481 ms
    tps = 102.176356 (without initial connection time)

used *pg_stat_statements* to fetch execution time for that query.

SELECT total_exec_time FROM pg_stat_statements where query = '<query here>'

got:

      total_exec_time
    --------------------
     12.242579000000001
    (1 row)

used *EXPLAIN ANALYZE*, got:

                                           QUERY PLAN

------------------------------------------------------------------------------------------------
 <query description>  (cost=0.00..0.01 rows=0 width=0) (actual
time=0.182..0.182 rows=0 loops=1)
   ->  Result  (cost=0.00..0.01 rows=1 width=230) (actual time=0.034..0.034
rows=1 loops=1)
 Planning Time: 0.021 ms
 Execution Time: 0.195 ms
(4 rows)


Now, which among these gives me the actual execution time of the query? Or
rather, how can i find out the actual execution time of the query?


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Finding execution time for a query
@ 2025-03-13 11:20  Laurenz Albe <[email protected]>
  parent: Prasanna Thirugnanasambandam <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Laurenz Albe @ 2025-03-13 11:20 UTC (permalink / raw)
  To: Prasanna Thirugnanasambandam <[email protected]>; [email protected]

On Thu, 2025-03-13 at 15:21 +0530, Prasanna Thirugnanasambandam wrote:
> How do I find the execution time of a query?

My Stackexchange answer didn't satisfy?
https://dba.stackexchange.com/a/345698/176905

Yours,
Laurenz Albe






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-03-13 11:20 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-03-13 09:51 Finding execution time for a query Prasanna Thirugnanasambandam <[email protected]>
2025-03-13 11:20 ` Laurenz Albe <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox