For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > 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?
go4anju@gmail.com

2006-07-27, 3:57 am

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 cant be shared, add clone() method etc. etc.

Can you please advice how can I do the same?

Please reply ASAP.

Many Thanks in advance.

Regards,
Anju

Nik J

2006-07-27, 6:57 pm

Well if you are writing to ONE excel sheet, I think you are going to
have trouble writing to it from 4 parallel processes, specifically the
clobbering of the first 3 processes when the last process attempts
writes to it.

What you might consider is writing to 4 separate files then merging the
file when all the processes are complete. If you want to know more
about threading the process read:

perldoc perlipc

on Unix:
perldoc -f fork

on Windows:
perldoc Win32::Process

fork/Win32::Process::Create will help you to spawn off processes.


go4anju@gmail.com 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 cant be shared, add clone() method etc. etc.
>
> Can you please advice how can I do the same?
>
> Please reply ASAP.
>
> Many Thanks in advance.
>
> Regards,
> Anju


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com