-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
cli: show latency with server #49450
Comments
@a-entin points out that we may want to somehow show server-side latency of each query (or show both). Even show the time-to-first-result-row separately from the time-to-last-result-row. I think these are great ideas, but we need to figure out the best way to get (or estimate) this information. We can avoid clutter by only showing the timing breakdown when these times are significantly different (e.g. big client-server latency). |
The doc says re time reporting in the built-in interactive SQL client... "Reveal the time a query takes to complete." This leaves much to interpretation. Through tests and observations, like timing of
[Extreme yet real world] Example:
Suggested behavior: Example: |
Previously, we did not show client-server latency for interactive sql connections. Now, a line is printed at the top when an interactive sql session begins which prints the client-server latency. Latency is measured by the time it takes the "get cluster version" query to return. Addresses cockroachdb#49450 Release note (cli change): cli now prints the client-server latency on startup.
Dug into this a bit, and here's my preliminary analysis: Currently, the time that we display is the end to end time it takes the client to send and receive back the result of a query. This means processing time on the server + the roundtrip. However, this does not include the time to render query results, which we track separately and alert on if the time it took to render is particularly high (higher than 1 second). So in some sense, we are doing what Vertica is doing, except we aren't printing the time it takes to format rows when the time is trivially small. The easiest fix involves printing the "client server latency" on startup, and measuring this by timing the query that gets the cluster version, as @RaduBerinde mentioned above. This may not be completely accurate, as this would include the timing for execution and planning of the query, but might suffice for all practical purposes -- we are timing a query that is relatively inexpensive to plan/execute, so the client/server latency will dominate. I've made a PR with this easy fix, which is linked above. On the other hand, we do store a bunch of statistics like service latency, execution latency, parsing latency, planning latency etc. on the server side in |
Have some concerns re printing the "client server latency" on startup, as a solution:
The first number, i.e. server side query execution should only include the time from beginning of the execution to the point the first record in the result set is emitted from the engine. No need to include even the time to buffer the result set on the server side. Note that the time reported in interactive SQL should closely correlate to the time report in Web UI |
Copying @knz 's comment on the PR linked above here:
|
I like the idea of adding a new observer statement This would allow us to display statistics such as the service time, execution time, planning time etc. (everything that we currently save in the StatsCollector). In the future, this can be expanded upon as/when we change how we bucket times on the server side. What does this mean in the context of this issue? All that being said, this will add a new user facing statement and there are considerations with that. I would love to get some additional thoughts on this from folks/if this is worth pursuing. |
Adds a new observer statement `SHOW LAST QUERY STATISTICS` which returns service, latency, planning, and parsing timigns for the last executed statement. By exposing these timings this PR builds a bridge towards providing more in-depth metrics to improve timings displayed by the CLI. Note that this new statement should probably not be exposed to users, and should only be used for internal use (and therefore I'm leaving the release note blank here). This is because the CLI issues some "under the hood" queries (eg. retriving the current db so that it can be displayed). If a user would use this statement without insight into these "under the hood" queries it could prove to be confusing. Informs cockroachdb#49450 Release note: none
Adds a new observer statement `SHOW LAST QUERY STATISTICS` which returns service, latency, planning, and parsing timigns for the last executed statement. By exposing these timings this PR builds a bridge towards providing more in-depth metrics to improve timings displayed by the CLI. Note that this new statement should probably not be exposed to users, and should only be used for internal use (and therefore I'm leaving the release note blank here). This is because the CLI issues some "under the hood" queries (eg. retriving the current db so that it can be displayed). If a user would use this statement without insight into these "under the hood" queries it could prove to be confusing. Informs cockroachdb#49450 Release note: none
Adds a new observer statement `SHOW LAST QUERY STATISTICS` which returns service, latency, planning, and parsing timigns for the last executed statement. By exposing these timings this PR builds a bridge towards providing more in-depth metrics to improve timings displayed by the CLI. Note that this new statement should probably not be exposed to users, and should only be used for internal use (and therefore I'm leaving the release note blank here). This is because the CLI issues some "under the hood" queries (eg. retriving the current db so that it can be displayed). If a user would use this statement without insight into these "under the hood" queries it could prove to be confusing. Informs cockroachdb#49450 Release note: none
50575: sql: add a new observer statement to show last query statistics r=solongordon a=arulajmani Adds a new observer statement `SHOW LAST QUERY STATISTICS` which returns service, latency, planning, and parsing timigns for the last executed statement. By exposing these timings this PR builds a bridge towards providing more in-depth metrics to improve timings displayed by the CLI. Note that this new statement should probably not be exposed to users, and should only be used for internal use (and therefore I'm leaving the release note blank here). This is because the CLI issues some "under the hood" queries (eg. retriving the current db so that it can be displayed). If a user would use this statement without insight into these "under the hood" queries it could prove to be confusing. Informs #49450 Release note: none Co-authored-by: arulajmani <[email protected]>
Previously, when a user executed multiple statements on a single line in the CLI, we would send the string as-is to the server. This would skew statement execution timings by attributing all of the server execution time to the first statement. This patch fixes this issue by parsing the supplied string on the client side and sending invididual statements one at a time. This is in line with Postgres behavior. Additionally, this patch also changes the way we calculate the time displayed by the CLI. Previously, we would show the time it took between a client sending a request and recieving a result. This would include the client-server latency as well. Now instead of showing the total time, we switch to showing just the server execution time. This is done by issuing the `SHOW LAST QUERY STATISTICS` query underneath the hood. Fixes cockroachdb#48180 Informs cockroachdb#49450 Release note (cli change): The way the CLI now shows the server execution timing instead of the total time it took to recieve results. This means factors such as rendering time and client server latency are no longer accounted for in the timings that the CLI prints for a query execution. Additionally, if multiple statements are supplied on a single line, the timings displayed now are a more accurate representation than before. Earlier the time displayed for the first statement included the processing time for all the statements supplied in that line. This is no longer the case as individual statement timings now represent only their execution times. This brings us in line with the postgres CLI.
Previously, when a user executed multiple statements on a single line in the CLI, we would send the string as-is to the server. This would skew statement execution timings by attributing all of the server execution time to the first statement. This patch fixes this issue by parsing the supplied string on the client side and sending invididual statements one at a time. This is in line with Postgres behavior. Additionally, this patch also changes the way we calculate the time displayed by the CLI. Previously, we would show the time it took between a client sending a request and recieving a result. This would include the client-server latency as well. Now instead of showing the total time, we switch to showing just the server execution time. This is done by issuing the `SHOW LAST QUERY STATISTICS` query underneath the hood. Fixes cockroachdb#48180 Informs cockroachdb#49450 Release note (cli change): The way the CLI now shows the server execution timing instead of the total time it took to recieve results. This means factors such as rendering time and client server latency are no longer accounted for in the timings that the CLI prints for a query execution. Additionally, if multiple statements are supplied on a single line, the timings displayed now are a more accurate representation than before. Earlier the time displayed for the first statement included the processing time for all the statements supplied in that line. This is no longer the case as individual statement timings now represent only their execution times. This brings us in line with the postgres CLI.
Previously, when a user executed multiple statements on a single line in the CLI, we would send the string as-is to the server. This would skew statement execution timings by attributing all of the server execution time to the first statement. This patch fixes this issue by parsing the supplied string on the client side and sending invididual statements one at a time. This is in line with Postgres behavior. Additionally, this patch also changes the way we calculate the time displayed by the CLI. Previously, we would show the time it took between a client sending a request and recieving a result. This would include the client-server latency as well. Now instead of showing the total time, we switch to showing just the server execution time. This is done by issuing the `SHOW LAST QUERY STATISTICS` query underneath the hood. Fixes cockroachdb#48180 Informs cockroachdb#49450 Release note (cli change): The way the CLI now shows the server execution timing instead of the total time it took to recieve results. This means factors such as rendering time and client server latency are no longer accounted for in the timings that the CLI prints for a query execution. Additionally, if multiple statements are supplied on a single line, the timings displayed now are a more accurate representation than before. Earlier the time displayed for the first statement included the processing time for all the statements supplied in that line. This is no longer the case as individual statement timings now represent only their execution times. This brings us in line with the postgres CLI.
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.
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.
52233: cli: improve interactive sql shell timings r=knz a=arulajmani 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 #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 #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. Co-authored-by: arulajmani <[email protected]>
We recently had some confusion related to measuring latency of queries from the interactive sql client. The client shows the end-to-end latency as measured from the client, so it includes any latency to the server. This is not obvious and/or one might not be aware that the latency to the server is significant.
It would help a lot if at the startup of the interactive client, we would print out the latency to the server (this could be obtained by using the latency of the query it runs already to get the current version).
The text was updated successfully, but these errors were encountered: