Bug #105934 | suggestion: time out support for incremental generation of results | ||
---|---|---|---|
Submitted: | 19 Dec 2021 21:11 | Modified: | 13 Jan 2022 16:07 |
Reporter: | Don Cohen | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S4 (Feature request) |
Version: | OS: | Any | |
Assigned to: | CPU Architecture: | Any |
[19 Dec 2021 21:11]
Don Cohen
[11 Jan 2022 17:13]
MySQL Verification Team
Hi, Thank you for your feature request. However, your feature already exists. You have to set _use_ result option instead of the default _store_ result option. Then, you will get rows as they are found. Regarding time limit, that is what we have a `kill` command for ..... the one for the statement and not for a connection ...... Setting time limit in a query would be very dangerous in many situations. Not a bug.
[11 Jan 2022 18:03]
Don Cohen
This is something in the c api ? A web search shows something about it in php mysqli. Is there some way to get the mysql command line client to use it? Or any other interactive program where I enter a select statement and then get the response delivered? Or is this only available in certain api's? Where should I look for doc to see which libraries or api's and how to use it? Also, what would be dangerous about the time limit? And how would setting a timelimit necessarily be different from using kill ?
[12 Jan 2022 20:25]
Don Cohen
So far I have been unable to demonstrate that this works in php. sample code: $uresult = $mysqli->query($query, MYSQLI_USE_RESULT); if ($uresult) { while ($row = $uresult->fetch_assoc()) { echo date('c') . $row['focal'] . PHP_EOL; } } What I want to see is different time stamps for different rows, or even better, just see them appear at different times. Instead they all appear at the same time with the same timestamp. This is a query of form select ... (select ...), (select ...) from ... where the time it takes with limit x is proportional to x (about .5 sec per row), and explain of the query shows | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | | 1 | PRIMARY | f | NULL | ALL | NULL | NULL | NULL | NULL | 9879 | 100.00 | NULL | | 3 | DEPENDENT SUBQUERY | g | NULL | ALL | day | NULL | NULL | NULL | 291012 | 1.11 | Range checked for each record (index map: 0x1) | | 2 | DEPENDENT SUBQUERY | g | NULL | ALL | day | NULL | NULL | NULL | 291012 | 1.11 | Range checked for each record (index map: 0x1) | so I at least expect that the results are being generated one at a time Perhaps I have to also use something like setFetchSize ? Is that an option in php ? Do you know where I can see an example of results appearing not all at once?
[13 Jan 2022 5:01]
Tsubasa Tanaka
What you need is Statement Execution Time Optimizer Hints? https://dev.mysql.com/doc/refman/8.0/en/optimizer-hints.html#optimizer-hints-execution-tim...
[13 Jan 2022 5:44]
Don Cohen
The max execution time doesn't seem to have much to do with streaming, but now that I try it, I can't get that to work either. In mysql client: select /*+ MAX_EXECUTION_TIME(1000) */ ... => ... 10 rows in set (4.190 sec)
[13 Jan 2022 16:07]
Don Cohen
BTW if I just set max_execution_time = 1000; then that does work to stop the execution, but I get no results back. What I want is to see the results that were found before the time limit was reached. So interrupting or killing statements etc. is only good enough if I can get the results to stream in the first place.