考虑什么“执行计划”或“CPU时间”? [英] What to consider "Execution Plan" or "CPU time"?

查看:84
本文介绍了考虑什么“执行计划”或“CPU时间”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个场景,其中将列的数据类型从varchar(max)更改为varchar(500)后,我可以看到执行中的重大改进计划(当我在同一个查询窗口中运行前后查询时)。

I have a scenario wherein after changing the datatype of a column from varchar(max) to varchar(500) I can see significant improvement's in the execution plan (when I run the before and after query in the same query window).

带varchar(max)的那个占总成本的82%,另一个是varchar(500)占用总成本的18%(因此在将数据类型从varchar(max)更改为varchar(800)之后具有显着优势)。

The one with varchar(max) takes 82% of the overall cost and the one with varchar(500) takes 18% of the overall cost (hence a significant benefit after changing the datatype from varchar(max) to varchar(800)).

但是,我看不出 CPU时间和经过时间,在这种情况下,使用varchar(800)查询的经过时间与使用varchar(max)的查询相比几乎是三倍,并且两个查询的CPU时间几乎相同。

However, I do not see any difference in the CPU time and the elapse time, in this case elapsed time of the query with varchar(800) is almost triple when compared to the one with varchar(max) and the CPU time is almost same for both the queries.

使用varchar(max)



  SQL Server执行时间:

    CPU时间= 391毫秒, 已用时间= 63 ms。

SQL Server解析和编译时间: 

    CPU时间= 0 ms,已用时间= 0 ms。



使用varchar(500)



  SQL Server执行时间:

    CPU时间= 422毫秒, 已用时间= 419 ms。

SQL Server解析和编译时间: 

    CPU时间= 0毫秒,已用时间= 0毫秒。

With varchar(max)

 SQL Server Execution Times:
   CPU time = 391 ms,  elapsed time = 63 ms.
SQL Server parse and compile time: 
   CPU time = 0 ms, elapsed time = 0 ms.

With varchar(500)

 SQL Server Execution Times:
   CPU time = 422 ms,  elapsed time = 419 ms.
SQL Server parse and compile time: 
   CPU time = 0 ms, elapsed time = 0 ms.

为什么它显示执行计划有所改善?

此致,Ashif Shaikh

Regards, Ashif Shaikh




推荐答案

百分比是估计值,所以你可以忽略它们。

The percentages are estimates, so you can disregard those.

首先你需要确保结果是一致执行查询至少约5次并删除所有奇数(高)数。如果你仍然看到varchar(500)的经过时间要长得多,那么就该检查执行计划了(Google
pastetheplan)。

First you need to make sure that the result is consistent Execute the queries at least some 5 times and remove all odd (high) numbers. If you still see that elapse time is much higher with varchar(500), then it is time to check out the execution plan (Google pastetheplan).


这篇关于考虑什么“执行计划”或“CPU时间”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆