问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/38636517/difference-between-pg-promise-duration-and-execution-time-in-explain-analyse-o