June 26, 2023 at 1:01 pm
Hi,
I am looking for some solution where i can find out how much time did sql take to give full output to the application i.e. time taken by the final select statement to give full output.
Regards,
Saumik Vora
June 26, 2023 at 6:41 pm
If you have SSMS, you could just run the SELECT by itself and it would show you how long it took.
However, if you need that via runtime, then you would either need to make that part of the SELECT statement, which while it will not be 100% accurate since the getting of the time (before and after) will take few fractions of a second, you would get a pretty good idea.
We do this for our reports (stored procedures that produce the report results) so that we have a historical record of how long each report took to run as well as whether it succeeded or failed. When we do this, we call a Stored Procedure that sets up the time variables and then does basically the following:
SET @StartTime = GETNOW( );
EXEC StoredProcedure;
SET @EndTime = GETNOW( );
First the above is pseudo-code and we of course then save that time data within a historical table, for reference later on. I hope that helps.
June 26, 2023 at 6:46 pm
GETNOW()? Do you mean GETDATE()?
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
June 26, 2023 at 9:20 pm
There are many factors to how long it will take SQL Server to deliver the results to a client - including network time and processing time from the client. If you want a general idea of how long a client takes you can enable 'Include Client Statistics' when running the query in SSMS which will give you a break down of how long each portion takes.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
June 26, 2023 at 9:28 pm
Thanks, and yeah GETDATE( ) or actually NOW( ) would be basically correct, I believe.
Note I have worked with so many languages sometimes the exact function names get a bit blurred but then again it is basically psuedo code anyway and all it needs to do is get the concept across and I am sure that GETNOW( ) conveys the concept of the retrieval of the current date and time and thus could then be easily tracked back to either the GETDATE( ) or the NOW( ) function --or-- maybe a totally different function that the user prefers to use for the retrieval of that kind of information.
June 27, 2023 at 6:47 am
Thanks, and yeah GETDATE( ) or actually NOW( ) would be basically correct, I believe.
Note I have worked with so many languages sometimes the exact function names get a bit blurred but then again it is basically psuedo code anyway and all it needs to do is get the concept across and I am sure that GETNOW( ) conveys the concept of the retrieval of the current date and time and thus could then be easily tracked back to either the GETDATE( ) or the NOW( ) function --or-- maybe a totally different function that the user prefers to use for the retrieval of that kind of information.
No need to get so defensive, just wanted to make sure that your code did not confuse other users.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply