how to set mysql max_execution_time property use go

huangapple go评论131阅读模式
英文:

how to set mysql max_execution_time property use go

问题

非常抱歉,我只能为您提供中文翻译,以下是您要翻译的内容:

非常抱歉问这个问题,但是在使用谷歌之后我没有找到有用的信息。

DBA可以防止慢查询影响MySQL服务器,所以我们需要控制SELECT语句的执行时间。我知道变量max_execution_time会影响这个,但是我在database/sql.go中找不到相关的函数。有哪位大神可以给我一些建议吗?

英文:

Im so sorry ask this but i have no useful msg after google.

dba prevent slow query affect mysql server, so we need control select statement execute time. I know variable max_execution_time affect that。 but i can not find func in dtabase/sql.go , Who big man can give me some advice

答案1

得分: 1

执行SET max_execution_time=500作为一个SQL语句。这将限制在同一连接上执行的后续SQL语句的执行时间为0.5秒。

也可以使用SQL注释提示,例如SELECT /*+ MAX_EXECUTION_TIME(1000) */ field1, field2 FROM tbl ...,就像这个答案中所示。

如果您在一个新问题中提供有关您的慢查询的详细信息,可能会有性能改进的可能性。

英文:

Execute SET max_execution_time=500 as a SQL statement. This limits the following SQL statements on the same connection to 0.5 seconds.

It is also possible as a SQL comment hint like SELECT
/*+ MAX_EXECUTION_TIME(1000) */ field1, field2 FROM tbl ...
like
this answer.
If you show details about your slow query in a new question performance improvements may be possible.

huangapple
  • 本文由 发表于 2022年2月25日 12:23:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/71261028.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定