-
Notifications
You must be signed in to change notification settings - Fork 33
Display time to execute when running SQL statements #357
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
Conversation
@@ -112,7 +112,8 @@ export class ResultSetPanelProvider implements WebviewViewProvider { | |||
columnHeadings: Configuration.get(`resultsets.columnHeadings`) || 'Name', | |||
queryId: this.currentQuery.getId(), | |||
update_count: queryResults.update_count, | |||
isDone: queryResults.is_done | |||
isDone: queryResults.is_done, | |||
executionTime: (endTime - startTime).toFixed() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is being sent for every request (e.g. the first request and the following page requests).
We actually only care about the execution time of the execute
call and not all of them.
You will have to add some code to only send the execution time for the first execute (perhaps you base it on getState()
), and undefined
for the following requests. The frontend will need to be updated to account for this.
FYI: Execution time is added to the server response from mapepire. Probably it doesn't make any difference unless there is some network latency between vscode and the server. Execution time will be available when mapepire is bumped. |
@janfh you are correct, but this PR does do the frontend work which makes it viable still. Then another PR should come in and replace the backend logic with the data from Mapepire when it's been merged. I am not ready to merge the Mapepire update yet. Still waiting on test feedback from some others. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is really close! Just a small snag on some types and we should be good to go.
src/views/results/html.ts
Outdated
@@ -379,7 +379,12 @@ export function generateScroller(basicSelect: string, isCL: boolean, withCancel? | |||
if (data.rows === undefined && totalRows === 0) { | |||
document.getElementById(messageSpanId).innerText = 'Statement executed with no result set returned. Rows affected: ' + data.update_count; | |||
} else { | |||
document.getElementById(statusId).innerText = (noMoreRows ? ('Loaded ' + totalRows + '. End of data.') : ('Loaded ' + totalRows + '. More available.')) + ' ' + (updateTable ? 'Updatable.' : ''); | |||
if (data.executionTime > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the backend you're using toFixed()
which returns a string, but here you're doing a numerical comparison. IMO, your backend code could send undefined
on the second time around.
let executionTime: number|undefined;
if (this.currentQuery.getState() == "RUN_MORE_DATA_AVAILABLE") {
queryResults = await this.currentQuery.fetchMore();
}
else {
const startTime = performance.now();
queryResults = await this.currentQuery.execute();
const endTime = performance.now();
executionTime = (endTime - startTime)
}
this._view.webview.postMessage({
// ...
executionTime //will send either a number or undefined
});
Then your frontend can do the toFixed
calculation.
if (data.executionTime) {
document.getElementById(statusId).innerText = (noMoreRows ? ('Loaded ' + totalRows + ' rows in ' + data.executionTime.toFixed() + 'ms. End of data.') : ('Loaded ' + totalRows + ' rows in ' + data.executionTime.toFixed() + 'ms. More available.')) + ' ' + (updateTable ? 'Updatable.' : '');
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @RobertNash1
#298
Resolved the ticket - added in performance metric (in milliseconds)