Performance and scalability: Performance improvements
I have a java program function which returns vector with 50,000 records in it.But from my JSP when i made a call to it and using 10 records per time.So, i want to improve the performance of my application.What is the best way to go?
- Performance improvements by Nagendra Prasad on July 22 2003 04:56 EDT
- JDBC Performance Tuning Tool by Dionn Schaffner on July 24 2003 17:43 EDT
- You could change your SQL by Pietari L on July 24 2003 21:41 EDT
- Use an object database by Bart Kooijman on August 06 2003 07:05 EDT
- Try Elvyx ... by Armando Perdomo on February 27 2007 18:23 EST
There is one thing I can suggest, but not sure whether it fits into the requirement or not.
1. One thing is sure, you will not display all the 50,000 records on the jsp page 10 at a time. Because if the user wants to go the 49000th record he has to press the next button 4900 times.
2. So why are you getting 10 records at a time to the jsp page. ?
3. Insted you can do one thing. Pull in this data into a Hashtable or Hashmap and based on the key value get the required information on the jsp page.
Assume that you are getting names in a vector like
Instead get them with a key and put into a hash table and retrieve only those records to the jsp page.
Now you can get the method that puts only the required records into a vector. Like between 1 to 3.
Then u can display these records in the jsp page.
To sum it up briefly.
Step:1 Put the records with a key in a hashtable or hashmap.
step:2 write a method that gets the required values into a vector.
step:3 display only those values in the jsp page.
Hope this helps.
You could try IronTrack SQL to help you identify what's going on. There is a free trial available.
If you're returning 50,000 records in a Vector, there'll be performance problems if you ever serialize those vectors, plus memory usage can grow pretty rapidly if many clients have separate vectors. Assuming you're getting the records from a database, some database servers allow you to choose just some of the records. This can help a lot if your data is static (no rows added or deleted when the records are viewed). If you're using Microsoft SQL Server, for example, take a look at this resource:
Using this method, you can reduce the number of records from 50,000 to just 10.
Maybe you can consider an object database instead of a RDBMS. They handle these types of problems much more effeciently with sort of lazy loading the content of vectors. They use the hollow object mechanism for it found in the JDO spec.
Otherwise you should further optimize your query that's used to pick up the 50.000 records. It should be redesigned to pick up the 10 needed by the JSP instead. Let the database do the job. It's designed to perform queries as quickly as possible. Java is not.
We were using p6spy and IronGrid but we could not find the IronGrid code to fix some bugs. Then, we started implementing a client for p6spy and we finished implementing the full solution. This application is Elvyx and can be downloaded from: http://www.elvyx.com I think this tool could be useful to the community. Armando ;-) http://www.elvyx.com