[cx-oracle-users] Creating a large number of database connections
Brought to you by:
atuining
From: Moore, P. <Pau...@at...> - 2004-01-15 11:54:38
|
I have a program which needs to connect to a large number of databases. Each connection is fairly short-lived (run a single SQL query), but the connect times can be quite long, particularly as some databases may be inaccessible due to network issues, and so there's a long wait for timeouts. What I'd like to do is to create all of my connections "in parallel", and then run the queries as the connections are ready. This would reduce the runtime of my application from the sum of all the connect times (plus a fixed overhead) to the maximum connect time (plus a possibly different fixed overhead). At the moment, I'm doing this using multiple threads, but the extra code needed to handle the threads, and to make sure that cursors are only used from a single thread, is non-trivial. And there's also Oracle's threading overhead. Is there a simpler way of doing this, that I am missing? I need a solution which will handle 100 or so connections, and will scale reasonably sensibly. My initial thought was that some form of non-blocking connect might work (I'm not an OCI expert), but when I scanned the OCI manuals, it doesn't seem like OCI lets you do any other database work while a nonblocking connect is in progress. Can anyone suggest anything? Thanks, Paul Moore. |