Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating an SQL for perfomace 1

Status
Not open for further replies.

crmayer

Programmer
Nov 22, 2002
280
US
I am making a change to a current program that gets payroll information being requested. I need to add quarter to date miles to this payroll request, but am having a hard time deciding what the best approach will be.

1) Call a method that runs a query 4 times for each quarter?

2) Call a method that runs a query once for all year, then sort through the query results to separate the quarters?

Is there a easy answer to this? If not, is there a way I can find out which one will perform the best? Time is an issue here, so I need the faster of the two ways. I have wrote the code to do option 1 and it is not too bad time wise, but could take up to 1 second per query, which is border line too long to tie up my application that is calling this method. Being new to Java I am not sure if there is a easy way to test the speed of this, or if it is just an easy answer that sorting query results is faster then running a query 4 times???

I would say that there is about 150 - 200 records for each quarter that it would have to sum up for each query..
 
Why not do some tests for the two methods to see which is quicker ?

--------------------------------------------------
Free Database Connection Pooling Software
 
That is what I was thinking, just was not sure if there was a way to analyze a query or something like that. The call to the query 4 times seems to be running pretty good. I will see what kind of results I get on the other method.
 
Thanks, it looks like my query is the best way to go....

Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top