MySQL-我可以限制查询运行的最大时间吗? [英] MySQL - can I limit the maximum time allowed for a query to run?

查看:571
本文介绍了MySQL-我可以限制查询运行的最大时间吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来限制mysql服务器上查询的最大运行时间.我认为可以通过my.cnf配置文件完成此操作,但是在文档中找不到任何相关内容.有人知道这是否可以完成吗?谢谢.

I'm looking for a way to limit the max running time of a query on mysql server. I figured this could be done through the my.cnf configuration file, but couldn't find anything relevant in the docs. Anyone knows if this could be done? thanks.

推荐答案

在向服务器发送查询以运行时,无法指定最大运行时间.

There is no way to specify a maximum run time when sending a query to the server to run.

但是,在数据库服务器上每秒运行一次cron作业并连接并执行以下操作并不少见:

However, it is not uncommon to have a cron job that runs every second on your database server, connecting and doing something like this:

  1. SHOW PROCESSLIST
  2. 查找所有查询时间大于您的最大期望时间的连接
  3. 为每个进程运行KILL [进程ID]

这篇关于MySQL-我可以限制查询运行的最大时间吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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