forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: improve interactive sql shell timings
Previously, the CLI displayed timings by timing a query on the client. This would include both the client-server latency and the query execution time, without bucketing which is what. This patch changes this by switching the way we calculate timings in the CLI. Instead of timing on the client, we now send a `SHOW LAST QUERY STATISTICS` query after a statement is executed. This allows us to display both the network latency and the network latency as separate values. Additionally, this patch no longer displays timings for queries that include multiple statements on one line. This is to mitigate cockroachdb#48180, where timings for executing all the statements are incorrectly attributed to the first statement. Actually fixing the issue is beyond the scope of this PR. Fixes cockroachdb#49450 Release note (cli change): The CLI no longer prints a blanket `Time` for queries. Instead, if `show_times` is turned on and the server version is >=20.2, the CLI prints two separate times -- the server execution time and the network latency. Release justification: low risk, high benefit change to existing functionality.
- Loading branch information
1 parent
cef838c
commit 5315685
Showing
9 changed files
with
179 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#! /usr/bin/env expect -f | ||
|
||
source [file join [file dirname $argv0] common.tcl] | ||
|
||
# This test ensures timing displayed in the CLI works as expected. | ||
|
||
spawn $argv demo movr | ||
eexpect root@ | ||
|
||
start_test "Test that server execution time and network latency are printed by default." | ||
send "SELECT * FROM vehicles LIMIT 1;\r" | ||
eexpect "1 row" | ||
eexpect "Server Execution Time:" | ||
eexpect "Network Latency:" | ||
|
||
# Ditto with multiple statements on one line | ||
send "SELECT * FROM vehicles LIMIT 1; CREATE TABLE t(a int);\r" | ||
eexpect "1 row" | ||
eexpect "Server Execution Time:" | ||
eexpect "Network Latency:" | ||
eexpect "CREATE TABLE" | ||
eexpect "Server Execution Time:" | ||
eexpect "Network Latency:" | ||
end_test | ||
|
||
start_test "Test show_server_execution_times works correctly" | ||
send "\\set show_server_execution_times=false\r" | ||
send "SELECT * FROM vehicles LIMIT 1;\r" | ||
eexpect "\nTime:" | ||
send "\\set show_server_execution_times=true\r" | ||
send "SELECT * FROM vehicles LIMIT 1;\r" | ||
eexpect "Server Execution Time:" | ||
eexpect "Network Latency:" | ||
end_test |
This file contains 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
This file contains 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
Oops, something went wrong.