Forums Register Login

Improving Database Query Execution Time from Data Access Object

+Pie Number of slices to send: Send
Hi,

I am writing a DAO object that will be retrieving data from 5 unrelated tables. The queries will be executing sequentially. I am thinking of creating a thread for each query, so they will execute in parallel to improve performance. Is this a good solution? I just read that there is an overhead for creating a Thread. I'm thinking also of creating a ThreadPool so I won't create thread anytime I need it. Any suggestion on how to create a good ThreadPool.

Thanks a lot.







+Pie Number of slices to send: Send
There are likely to be far bigger overheads running the queries and streaming the results back over the network, and that work is not going to change regardless of whether you run sequentially or in parallel. Why don't you try both approaches and see which performs better?
+Pie Number of slices to send: Send
I will try both approach and benchmark the result. I'm too concern about the performance since the application will be used by an organization with low end server machines due to budget constraints. I'm trying to improve execution time by fine tuning the codes of the application.
+Pie Number of slices to send: Send
First benchmark and then let us know what your results are. From there we can help you tune this.

For background threads, read up on how to use futures in Java http://java.sun.com/javase/6/docs/api/java/util/concurrent/Future.html

Kees Jan
+Pie Number of slices to send: Send
Won't independent queries require independent connections?

You might be execute faster at the expense of hogging
the connections?
+Pie Number of slices to send: Send
That's where the careful measurement of the benchmark comes in. :-) You won't know until you try on the production hardware.
+Pie Number of slices to send: Send
At the risk of derailing the topic slightly. How did you end up requiring data from 5 unrelated tables yet requiring said data for a single DAO? What is the relationship and why does it not have a similar relationship in your data model. The reason I'm asking is because if you can add said relationship in your data model you can probably create a single query to retrieve all required data for your DAO and let the database worry about optimizations such as parallelism, fetch buffers, caching, etc.
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1366 times.
Similar Threads
Thread pool in
Managing File resources
Threading strategy for the server (long)
JBoss Basic ThreadPool
How are thread identified in threadpool
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:55:34.