postgres的 Planning Time和Execution Time区别

Planning Time和Execution Time相差很大,其实互相比较没什么意思

因为Planning Time是指定一个执行查询的最快方式(计划)所需的时间,postgres有一个 "query planner" 来实现的

而Execution Time是运行这个最快的查询计划,并且将结果输出的时间

下面国外的文章很好的解释了两者的区别:

  1. You write a query in SQL which is some kind of "script" that you try to tell the server what you want from him.
  2. Most of the times there is many ways for server to collect data you ask for by writing query. There is where mechanism called "query planner" comes in to action. It tries to find the quickest way (plan) of execution of your query. It's doing so by estimates execution time of several possible ways (plans).
  3. Server runs the query using the plan which is thought as the quickest one.
  4. Server returns you the output.

EXPLAIN command prints you description of that process. Now:

  • Execution time on EXPLAIN output is time server spent on steps 3-4.
  • Planning time on EXPLAIN output is time server spent on step 2 only. I believe you think of it as "time planner thinks that query would take", but that can be called "planned [execution] time" or "estimated execution time".

参考:https://stackoverflow.com/questions/33549914/why-planing-time-and-execution-time-are-so-different-postgres

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值