asp.net 中 SP 的估计成本
在我的 asp.net 应用程序中,我想向用户展示当他提交表单时该存储过程将花费多少时间。有什么办法可以从asp.net应用程序中找到吗?就像我们在 sql server 中估计查询计划和估计成本一样。我们可以在asp.net网页上显示它吗?
In my asp.net application, I want to show the user that when he is submitting the form how much time does that stored procedure is going to take. Is there any way I can find out from asp.net application? Just like we have estimated query plan with estimated cost in sql server. Can we show it on asp.net webpage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只能通过记录过去的执行、计算平均值并告诉用户所需的平均时间来估计时间。
您还可以使用动态管理视图和函数来查询 SQL Server 相关信息SP。
You can only estimate the time by taking record of past executions, making an average and telling the user the average time that it will take.
You can also use Dynamic Management Views and Functions to query SQL Server about this SP.
您可以使用该命令
,然后运行查询(这不会运行它,但会返回一个 XML。然后您可以解析该 XML 以获取您想要的估计属性。
的示例 XML
输出
以上是您的请求的字面解释,但“成本”没有重要意义。它是一个没有度量单位且与时间没有任何相关性的统计值,
以免其他查询(使用连接池时情况更糟)停止工作,因为它们开始返回 XML 计划。 ...
You could use the command
and then run the query (which wouldn't run it but would return an XML. You can then parse the XML for the Estimated attributes you are after.
Sample XML for
Output
The above is a literal interpretation of your request, but "cost" bears no significant meaning. It is a statistical value with no unit of measure nor any correlation to time.
Best to use a new connection lest other queries (worse with connection pooling) stop working because they start returning the XML plan...