0

I am using 'duration' property from data object of 'result' function to measure the duration of execution of my query.

I tried the same query in pgAdmin with "EXPLAIN ANALYSE".

Both have a big difference.

can anyone say why is this?

which is the right approach to measure the execution duration of my query.

John
  • 465
  • 2
  • 8

1 Answers1

0

EXPLAIN ANALYSE is a performance perspective internal to the server only.

duration provided by method result of pg-promise includes:

  • preparing the query for execution
  • sending the query into the server
  • receiving and parsing the query by the server
  • executing the query (your EXPLAIN ANALYSE duration)
  • serializing the data and sending the response back
  • receiving data by the client
  • deserializing and converting data into JSON
  • notifying your code about the data

That's where the difference comes from.

vitaly-t
  • 24,279
  • 15
  • 116
  • 138
  • I have written a gulp task to measure execution duration in which i print the duration field of result method as the query execution time. But i cannot find any difference the duration time after and before indexing where as i can find the difference when i run EXPLAIN ANALYSE In pgAdmin – John Jul 29 '16 at 06:07