MS SQL 中查询的优先级
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/60878/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Priority of a query in MS SQL
提问by Brian R. Bondy
Is there a way to tell MS SQL that a query is not too important and that it can (and should) take its time?
有没有办法告诉 MS SQL 查询不是太重要,它可以(并且应该)花时间?
Likewise is there a way to tell MS SQL that it should give higher priority to a query?
同样,有没有办法告诉 MS SQL 它应该给予查询更高的优先级?
采纳答案by GilaMonster
Not in versions below SQL 2008. In SQL Server 2008 there's the resource governor. Using that you can assign logins to groups based on properties of the login (login name, application name, etc). The groups can then be assigned to resource pools and limitations or restrictions i.t.o. resources can be applied to those resource pools
不在 SQL 2008 以下的版本中。在 SQL Server 2008 中有资源调控器。使用它,您可以根据登录的属性(登录名、应用程序名称等)将登录分配给组。然后可以将组分配给资源池,并且可以将资源限制或限制应用于这些资源池
回答by Kilhoffer
SQL Server does not have any form of resource governor yet. There is a SET option called QUERY_GOVERNOR_COST_LIMIT but it's not quite what you're looking for. And it prevents queries from executing based on the cost rather than controlling resources.
SQL Server 还没有任何形式的资源调控器。有一个名为 QUERY_GOVERNOR_COST_LIMIT 的 SET 选项,但这并不是您要找的。并且它阻止基于成本而不是控制资源执行查询。
回答by Dan Williams
I'm not sure if this is what you're asking, but I had a situation where a single UI click added 10,000 records to an email queue (lots of data in the body). The email went out over the next several days so it didn't need to be a high priority, in fact it would bog the server every time it happened.
我不确定这是否是您要问的问题,但我遇到过这样的情况,即一次 UI 单击会将 10,000 条记录添加到电子邮件队列(正文中有大量数据)。这封电子邮件在接下来的几天内发出,因此它不需要成为高优先级,事实上,每次发生它都会使服务器陷入困境。
I split the procedure into 10,000 individual calls, ran the process on the UI in a different thread (set to low priority) and set it to sleep for a second after running the procedure. It took a while, but I had very granular control over exactly what it was doing.
我将该过程拆分为 10,000 个单独的调用,在不同线程(设置为低优先级)中的 UI 上运行该过程,并在运行该过程后将其设置为休眠一秒钟。这花了一段时间,但我对它正在做什么有非常精细的控制。
btw, this was NOT spam, so don't flame me thinking it was.
顺便说一句,这不是垃圾邮件,所以不要认为我是垃圾邮件。