Show query status and timings while waiting - #2278
Open
rolandwalker wants to merge 1 commit into
Open
rolandwalker wants to merge 1 commit into
rolandwalker wants to merge 1 commit into
Conversation
rolandwalker
force-pushed
the
RW/show-query-status-in-foreground-with-rendering
branch
from
September 28, 2026 20:43
5dc3345 to
e37fc4d
Compare
While a query is running, and while output is prepared, the current mycli UI is entirely blank. (Less than a lack of feedback: the prompt-toolkit toolbar even disappears.) Better practice would be to tell the user what is happening. Here we run the MySQL query in a thread, and print the query status every half-second by default. The status is accompanied by the elapsed time. A spinner from yaspinner was also considered. A spinner is more tidy; the timings give more information. The query status string is derived from running SHOW PROCESSLIST in a separate monitoring connection, and a few pseudo-states are added beyond those listed in * https://dev.mysql.com/doc/refman/9.7/en/general-thread-states.html including the important pseudo-state "rendering", which we learned here can take a substantial amount of time for results on the order of 100K rows or above. The MySQL thread states are very inconsistent on casing, which looked janky, so all are rendered as lowercase. Care is taken to catch interrupts and cancel background threads correctly. There is a new file query_runner.py, outside of which impact on non- test files is happily low. Drawbacks: * only a few server states account for most of what is visible at a reasonable sampling resolution. Suggestions for future work: * remember all of the states/timings for an extended textual timing summary at the end; a simpler SHOW PROFILES * show prompt-toolkit toolbar during query * show transforms as a separate state "transforming" * it is possible to see the "executing" state multiple times, and not clear if that is a good thing * it would be best to almost never see "finding state", but it shows briefly at the start some times, in some configurations
rolandwalker
force-pushed
the
RW/show-query-status-in-foreground-with-rendering
branch
from
September 28, 2026 20:46
e37fc4d to
0d4b1a1
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
While a query is running, and while output is prepared, the current mycli UI is entirely blank. (Less than a lack of feedback: the prompt-toolkit toolbar even disappears.)
Better practice would be to tell the user what is happening. Here we run the MySQL query in a thread, and print the query status every half-second by default.
The status is accompanied by the elapsed time. A spinner from
yaspinnerwas also considered. A spinner is more tidy; the timings give more information.The query status string is derived from running
SHOW PROCESSLISTin a separate monitoring connection, and a few pseudo-states are added beyond those listed inincluding the important pseudo-state
rendering, which we learned here can take a substantial amount of time for results on the order of 100K rows or above.The MySQL thread states are very inconsistent on casing, which looked janky, so all are rendered as lowercase.
Care is taken to catch interrupts and cancel background threads correctly.
There is a new file
query_runner.py, outside of which impact on non- test files is happily low.Drawbacks:
Suggestions for future work:
SHOW PROFILEStransformingexecutingstate multiple times, and not clear if that is a good thingfinding state, but it shows briefly at the start some times, in some configurationsExample: this video is from an early draft, but the idea is put across, including the amount of time spent on client-side rendering:
mycli_query_progress_rendering.mov
Checklist
changelog.mdfile.AUTHORSfile (or it's already there).