Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Parallel::ForkManager, DBI using memory

by iblech (Friar)
on Nov 08, 2004 at 18:18 UTC ( #406153=note: print w/ replies, xml ) Need Help??


in reply to Re: Parallel::ForkManager, DBI using memory
in thread Parallel::ForkManager, DBI using memory

Is there a reason you can't share one $dbh for all children? (I think this is possible with Parallel::ForkManager.)

No, it is not possible.

Reason: Think of two childs, both want to make a query:

# Child 1:
SELECT * FROM foobar WHERE baz = 3

# Child 2:
SELECT grzbaka FROM baz WHERE foo = 5

Now, both send their queries at the same time. The db server might receive:

SELECT * FROSELECT grzbaka FROM baM foobar WHERE baz = 3z WHERE foo = 5

Of course, reality is more complex, this example is just meant as a simple explanation why one db connection used by many childs don't work (as expected).

BTW, if you do cooperative multitasking, like POE does, everything is ok -- there is only one process which sends data to the db server.


Comment on Re^2: Parallel::ForkManager, DBI using memory
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://406153]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2015-07-28 10:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls