This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Performance and the fly likes Run two resultsets in two seperate threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Run two resultsets in two seperate threads" Watch "Run two resultsets in two seperate threads" New topic
Author

Run two resultsets in two seperate threads

sridhar gandikota
Ranch Hand

Joined: Jul 09, 2008
Posts: 31
Hello Ranchers,

I want to know can I run two resultsets in two seperate threads i mean one resultset in one thread and the other in other thread?

I just want to speed up execution of sql queries . By this process Can I improve the output performance?

DB is oracle 10g.

Please let me know if this is possible?

If so can you please provide with a Example please....

With Regards,
Sridhar
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 860
Yes, you can do it. It is tough to say if it will help performance or not. For example if you are cpu bound it probably won't. You should write some test code. Actually before you do that you should profile your current code and see where the bottleneck is and see where that leads you.


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi Steve ,

It is tough to say if it will help performance or not.


I am surprised by your answer , why is that you were mentioning that it may not improve performance .

Could you please tell me why it will not improve performance if we use Threads parallelly for query processing .

Thanks in advance .


Save India From Corruption - Anna Hazare.
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 860
Because it may not be your bottleneck (part of your program that is slow). For example say the database is 100% cpu pegged while running one query. Adding a 2nd query to an already overloaded server would make performance worse. This is just one example any other number of reasons could make such a change ineffective. The key with performance tuning is ALWAYS to know what you're bottleneck is before trying to tune. We could better help you if you posted some of your performance numbers for different parts of your code.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

The Oracle database can actually do it all for you. I'd strongly suggest to read what Oracle itself has to offer on parallel processing: http://download.oracle.com/docs/cd/B10501_01/server.920/a96520/tuningpe.htm

The solution already built by Oracle will very probably perform much better than any code outside of the database, avoiding many serious problems you would have to solve (How to partition the query into two or more equally sized parts? How to make sure the returned resultsets are consistent with each other? etc). Oracle can do all this easily as it has all information it needs at hand.

However, as Steve hinted, the basic question is whether the parallel processing can actually help in your case. It is quite advanced concept and your reaction to Steve's answer indicates you're not very familiar with the subject. I'd discourage you to go that path unless you understand it really thoroughly. In any case, if it later turns out that you really can utilize the parallel processing, it can easily be added to your code by slight modifications of the SQL statement(s) and/or schema tables, without any need to modify the Java code itself.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

For example say the database is 100% cpu pegged while running one query. Adding a 2nd query to an already overloaded server would make performance worse.

Thanks Steve .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Run two resultsets in two seperate threads
 
Similar Threads
Its Simple ! Thread and Runnable ! Help me out !
threading single instance vs multiple instances
thread's
address space?
Design Pattern to handle exceptions in multi-threaded frameworks