如何在 MySql 中限制查询或确定查询优先级

发布于 2024-09-07 07:40:02 字数 196 浏览 1 评论 0原文

MySQL 中是否有办法对查询进行优先级排序或限制?

我是服务器上的 DBA,我发现大量未优化的查询进入服务器,它们只会破坏 CPU。我正在考虑限制某些以不良方式访问数据库的用户。

澄清:

我意识到MySQL内置了限制查询、连接数量等的设施。但这些并不是真正的问题,而是用户千载难逢地会发送未经优化的查询,我需要超时或类似的事情。

Is there anyway to prioritize or throttle a query at all in MySQL?

I'm a DBA on a server that sees a lot of unoptimized queries come into the server and they just destroy the CPU. I'm looking at throttling certain users that hit on the database in poor fashion.

Clarification:

I realize that MySQL has facilities built in to limit number of queries, connections, etc. But those aren't really the issue, it's that once in a blue moon a user will send an unoptimized query, and I'd need to time it out or something similar.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

じ违心 2024-09-14 07:40:02

http://dev.mysql.com/doc/refman/4.1 /en/user-resources.html

从 MySQL 4.0.2 开始,您可以限制单个帐户对以下服务器资源的访问:

帐户每小时可以发出的查询数量

帐户更新的数量每小时可以发出

帐户每小时可以连接到服务器的次数

其他信息 -

MySQL 没有查询超时值,也没有任何其他内置方法来限制单个查询。然而,编写一个终止长时间运行的查询的脚本是非常简单的。您甚至可以捕获用户和查询,以便稍后击败有问题的用户/程序员。

这里是一个使用 PERL 的示例。

http://dev.mysql.com/doc/refman/4.1/en/user-resources.html

Starting from MySQL 4.0.2, you can limit access to the following server resources for individual accounts:

The number of queries that an account can issue per hour

The number of updates that an account can issue per hour

The number of times an account can connect to the server per hour

Additional Info -

MySQL does not have a query timeout value, or any other built-in way to throttle an individual query. However, it is pretty trivial to write a script that will kill long-running queries. You could even capture the user and query so that you can beat the offending user/programmer later.

Here is an example of one using PERL.

转瞬即逝 2024-09-14 07:40:02

我知道 phpMyAdmin 有一个区域用于每小时最大查询数、每小时最大更新数、每小时最大连接数和每个用户的最大用户连接数。除了 phpMyAdmin 之外,可能还有其他方法来设置这些值

I know that phpMyAdmin has an area for Max # of Queries per hour, Max # of Updates per hour, Max # of Connections per hour, and Max # of User Connections per user. There are probably other ways to set these values other than phpMyAdmin

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文