Hello all,
How do I find the execution time of a query?
I tried these methods:
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?used pg_stat_statements to fetch execution time for that query.
initial connection time = 12.481 ms
tps = 102.176356 (without initial connection time)
SELECT total_exec_time FROM pg_stat_statements where query = '<query here>'
got:
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?
total_exec_timeused EXPLAIN ANALYZE, got:
--------------------
12.242579000000001
(1 row)
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?