• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Run two resultsets in two seperate threads

 
sridhar gandikota
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic