Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CallableStatement and ResultSet - Performance Issue

 
Ponery Nishad
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a result set object which contains more than 3000 records and 10 columns returned through a callable statement. And I am making an arrayList which contains string[] out of the result set.

The structure is like ...



But it is taking more than 2 mins for the iteration through the java code.

Please find the the code block...



Please help me to fine tune this code so that I can iterate the records fastly.

Thanks in advance...

regards,
nponery
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ponery,
The first step is to find the bottleneck. Common places are:
1) The stored proc itself - how long does the query take?
2) Bandwidth - are you using all the data that gets returned
 
Ponery Nishad
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,

Thank you very much for the reply.

Please see the details for your questions.

1) The stored proc itself - how long does the query take?
The procedure excecution is taking hardly 6-7 seconds. (since db contains huge data volume).
2) Bandwidth - are you using all the data that gets returned
Yes. But I felt, its not a problem with bandwidth.

I am using BEA WL 8 in Unix Box with 8GB RAM and 3GHz Processor Speed (also using DataSource and weblogic connection pool) and Oracle DB is located in Remote Machine.

I found the problem is in the above code snippet I mentioned.

Please find the code with the execution time it has taken




This code block took 2 mins and 53 seconds to complete the iteration.

I would like to know, when we call rs.next()/rs.getString() "Will it hit DB for each call to retrieve the info on resultset object??? "

If yes, please suggest me some other good approach. If no, how to fine tune this code?

Thanks again...

regards,
nponery
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The stored proceure is taking 6-7 seconds to prepare the cursor, however you are processing the data in your java code which includes the execution time.
I am also interested to know if you are executing procedure on server itself on executing it from any sql client.

1) Can you remove inner for loop and extract the data for all 10 columns and provide us timing
2)provide the timing when you extract one column only.

Shailesh
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The loop doesn't look like it would take that long. You could test its performance without the query by simply assigning the same string to all values in the data structure. Also you could use jamon for timing your sql and jdbc methods.
 
Ponery Nishad
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Problem is with the resultset object. Since it is a CONNECTED one, if I call rs.next() or rs.getString(), it has an overhead to reach db and come.

(As I told earlier, the resultset fetches 2042 rows and 10 columns = 20420)

Now I am trying with another approach using CachedRowSet, which uses DISCONNECTED concepts.

I am using PL/SQL for querying.

In my PL/SQL procedure I have 5 in IN parameters and 2 OUT parameters(which are cursors).



where con is my connection object.


Since I am not able to set the out params, it is giving the below exceptions.



This exception means, code is able to call the PL/SQL.

We have callableStatement.registerOutParameter(<index>,<SQLType>) method in CallableStatement.

What is the similar method using CachedRowSet or how to set the OUT param values using CachedRowSet concept?

Please throw some light on this issue...

regards,
Nishad P
 
Ponery Nishad
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OR is there any other way/approach to use the DISCONNECTED concept to call the PL/SQL with OUT parameter(s) ?
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic