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.
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?
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.
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.
Post by:autobot
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
a bit of art, as a gift, the permaculture playing cards