Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Support MAX_EXECUTION_TIME #7008

Closed
xinwu5 opened this issue Jul 6, 2018 · 5 comments · Fixed by #10541
Closed

Feature Request: Support MAX_EXECUTION_TIME #7008

xinwu5 opened this issue Jul 6, 2018 · 5 comments · Fixed by #10541
Assignees

Comments

@xinwu5
Copy link

xinwu5 commented Jul 6, 2018

We use max_execution_time out this variable very often to control the max execution time from serverside for the queries. We would like to request TiDB can support this feature, or at least release a version to not report an error when using this variable at first. So it can unblock us for further testing.

https://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html#optimizer-hints-execution-time

  1. What did you do?
mysql> SELECT /*+ MAX_EXECUTION_TIME(1000) */ 1 ;
ERROR 1105 (HY000): line 1 column 38 near " 1" (total length 40)
  1. What did you expect to see?
mysql> SELECT /*+ MAX_EXECUTION_TIME(1000) */ 1 ;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
  1. What did you see instead?
mysql> SELECT /*+ MAX_EXECUTION_TIME(1000) */ 1 ;
ERROR 1105 (HY000): line 1 column 38 near " 1" (total length 40)
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v2.0.4-15-g14552af
Git Commit Hash: 14552afb4228c87f746c884c1548abc3eea4035e
Git Branch: release-2.0
UTC Build Time: 2018-07-04 11:56:13
GoVersion: go version go1.10.2 linux/amd64
TiKV Min Version: 2.0.0-rc.4.1
1 row in set (0.00 sec)
@morgo
Copy link
Contributor

morgo commented Jul 6, 2018

As an aside, the 5.7+ optimizer hints /*+ */ have a defined semantic of hint and not directive.

i.e. They can raise warnings, but should never raise errors.

@shenli
Copy link
Member

shenli commented Jul 7, 2018

@xinwu5 Thanks for your feedback!
We will support this syntax soon. The first step would be accepting the syntax and ignoring it.

@lysu
Copy link
Contributor

lysu commented Jul 7, 2018

relate to this statment level hint, 5.7 also introduce max_execution_time variable to control execution time in global/session level(https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_execution_time), also will need be support in future.

@shenli
Copy link
Member

shenli commented Jul 9, 2018

@xinwu5 Please try the latest master.

@morgo morgo reopened this Nov 24, 2018
@morgo
Copy link
Contributor

morgo commented Nov 24, 2018

As described above, the syntax is parsed but currently ignored. I suggest we leave this issue open until the feature is implemented. Here is a minimal test-case:

SELECT /*+ MAX_EXECUTION_TIME(1000) */ sleep(10) ;

mysql57> SELECT /*+ MAX_EXECUTION_TIME(1000) */ sleep(10) ;
+-----------+
| sleep(10) |
+-----------+
|         1 |
+-----------+
1 row in set (1.00 sec)

tidb> SELECT /*+ MAX_EXECUTION_TIME(1000) */ sleep(10) ;
+-----------+
| sleep(10) |
+-----------+
|         0 |
+-----------+
1 row in set (10.00 sec)

tidb> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v2.1.0-rc.3-219-g1e0876fe8-dirty
Git Commit Hash: 1e0876fe810a832721aac52275dd2b7792fd2892
Git Branch: flush
UTC Build Time: 2018-11-24 01:12:47
GoVersion: go version go1.11 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
1 row in set (0.01 sec)

@morgo morgo mentioned this issue Dec 10, 2018
70 tasks
db-storage added a commit to db-storage/tidb that referenced this issue May 29, 2019
- This feature is request by [Feature 7008](pingcap#7008).
- Add support for system variable "session.max_execution_time" and "global.max_execution_time".
- Support hint in  Select Statement linke: "SELECT /*+ MAX_EXECUTION_TIME(1000) */ * FROM t1".
- Add some unit test for the above(all tests passed).
db-storage added a commit to db-storage/tidb that referenced this issue May 29, 2019
- This feature is request by [Feature 7008](pingcap#7008).
- Add support for system variable "session.max_execution_time" and "global.max_execution_time".
- Support hint in  Select Statement linke: "SELECT /*+ MAX_EXECUTION_TIME(1000) */ * FROM t1".
- Add some unit test for the above(all tests passed).
@shenli shenli removed the status/TODO label Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants