Home > Archive > PERL Miscellaneous > July 2006 > How to use threads to parallelise 4 different DB connections?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to use threads to parallelise 4 different DB connections?
|
|
|
| Hi ,
My script is making connection to the four databases one by one and
writing the output to a single excelsheet. But there being huge
records, its taking too much time ( 4 hours), which is not acceptable.
So I need to synchronise the process so that the connection is made to
all the 4 DBs at one time and they run parallely.
I tried using Perl threads/ ithreads for the same but its giving
problem, like handles can't be shared , use clone() method etc. etc.
Can you please advice how can I do the same?
Please reply ASAP.
Many Thanks in advance.
Regards,
Anju
| |
| Nick of course 2006-07-27, 7:59 am |
|
anju wrote:
> Hi ,
>
> My script is making connection to the four databases one by one and
> writing the output to a single excelsheet. But there being huge
> records, its taking too much time ( 4 hours), which is not acceptable.
>
> So I need to synchronise the process so that the connection is made to
> all the 4 DBs at one time and they run parallely.
>
> I tried using Perl threads/ ithreads for the same but its giving
> problem, like handles can't be shared , use clone() method etc. etc.
>
> Can you please advice how can I do the same?
>
> Please reply ASAP.
>
> Many Thanks in advance.
>
> Regards,
> Anju
I'm assuming that the excessive time taken is due to database access
and/or intermediate processing - there is no way it can take 4 hours to
write to a spreadsheet; they just don't get that big. Use four
separate processes (not threads) running in parallel that write to
intermediate files (maybe use Storable for efficiency) then a final
process to write the spreadsheet. As a solution, it is a lot simpler
and more robust than using threads.
| |
|
|
|
|
|