执行前查询执行时间 [英] Query execution time before execution

查看:107
本文介绍了执行前查询执行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何在查询(即DML操作或函数或过程)之前获得准确的执行时间.例如,考虑到我有一个名称为Proc_123的参数化过程,执行该过程需要5分钟.我的情况就像在每次调用Proc_123时一样,应该在执行之前显示执行时间.

Hi ,

How can i get the accurate execution time for a query(i.e, DML operations or functions or procedures) before it is executed. For example consider that i have a parameterised procedure by name Proc_123 and it takes 5 mins to execute. My scenario is like whenever the Proc_123 is called, execution time should be displayed before it is executed.

推荐答案

那还有意义吗?查询将取决于很多因素,尤其是数据量-在执行之前,您希望如何找到准确的执行时间?

我不认为你可以.去和问您的人谈谈.
Does that even make sense? A query which would depend on lots of factors especially amount of data - how do you expect to find accurate execution time BEFORE it is executed?

I don''t think you can. Go and talk to the person whoever has asked this from you.


在执行之前,最好的猜测是优化计算出的估计运行时间.因此,如果您从计划中获取估算值,则可以使用它.

但是,如果您有存储过程,它就不那么容易了.优化是在语句级别完成的,因此您将必须对要在过程中执行的语句的所有估计求和.可以这样做,但是很可能您必须重新设计程序.

还请记住,这是一个估计值.实际的运行时间可能会更长或更短,因此您不能将其视为一个精确值,因此实际上无法使用倒数计时器.
Before execution, the best guess that you can have is the estimated run time the optimization has calculated. So if you fetch the estimation from the plan you can use that.

However, it''s not that easy if you have a stored procedure. The optimization is done on a statement level so you would have to sum all the estimations for the statements to be executed in the procedure. This can be done, but most likely you have to redesign you procedure.

Also remember that this is an estimate. The actual run time may be less or more so you cannot treat this as an exact value, so you actually cannot use a countdown timer.


我需要这样做,因为 我需要计算过程或函数的哪个部分需要花费更多的时间来执行 .有了这个我可以直接去那一部分,并微调查询.如果这不可能,请告诉我解决问题的最佳方法(计算过程或函数的哪一部分需要花费更多时间执行)
Im in need for this because i need to calculate which part of the procedure or function is taking more time to execute. With this i can go directly to that part and fine tune the query. If this is not possible, let me know the best way to achieve my issue(to calculate which part of the procedure or function is taking more time to execute)


这篇关于执行前查询执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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