Difference between pg-promise 'duration' and execution time in EXPLAIN ANALYSE of postgres?

流过昼夜 提交于 2019-12-25 07:13:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!