Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 885557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:55:47+00:00 2026-05-15T12:55:47+00:00

im interested in performing multiple database actions in parallel. I have played with Perl

  • 0

im interested in performing multiple database actions in parallel. I have played with Perl Parallel::ForkManager but not used it with any databases yet. I have read that database connectivity is not supported very well with this. Does anyone have experience with this?

As an example i would probably be spawning a system call(which does the DBI work) NOT raw code, i.e.

#!/opt/local/bin/perl -w

use strict;
use Parallel::ForkManager;

$| = 1;

my $max_procs = 10;

my $pm =  new Parallel::ForkManager($max_procs);

for (my $var = 0; $var <= 10; $var++) {
  my $pid = $pm->start('proc'.$var) and next;
  sleep ( 2 );
  system( "./DBworker.pl $var" );
  $pm->finish(0); 
}

print "Waiting for child procs\n";
$pm->wait_all_children;
print "complete!\n";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:55:47+00:00Added an answer on May 15, 2026 at 12:55 pm

    If the work is being done by other programs, there is no danger to forking. The danger comes when you open a connection to the database and then fork. The child can’t reuse the parents connection; however, take a look at DBIx::Connector, it handles the things you need to do after forking for you and running multiple programs is generally not the right answer.

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    use DBIx::Connector;
    use Parallel::ForkManager;
    
    my $dsn  = "dbi:SQLite:dbname=foo.db";
    my $user = "";
    my $pass = "";
    my $conn = DBIx::Connector->new($dsn, $user, $pass, 
        {
            AutoCommit       => 0,
            PrintError       => 0,
            RaiseError       => 1,
            ChopBlanks       => 1,
            FetchHashKeyName => 'NAME_lc',
        }
    );
    END { unlink "foo.db" }
    
    #setup table
    $conn->run(fixup => sub {
        my $dbh = $_;
        $dbh->do("create table foo ( id integer, name char(35) )");
        my $sth = $dbh->prepare("insert into foo (id, name) values (?, ?)");
        while (<DATA>) {
            chomp;
            $sth->execute(split /,/);
        }
    });
    
    my $pm = Parallel::ForkManager->new(3);
    
    my $sth = $conn->dbh->prepare("select * from foo where id = ?");
    for my $id (1 .. 3) {
        next if $pm->start;
        $sth->execute($id);
        while (my $row = $sth->fetchrow_hashref) {
            print "$id saw $row->{id} => $row->{name}\n";
        }
        $pm->finish;
    }
    
    $pm->wait_all_children;
    
    print "done\n";
    
    __DATA__
    1,foo
    2,bar
    3,baz
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm primarily interested in popular and widely used compilers, such as gcc. But if
everyone seems interested in building IPhone apps today. Do you have to have an
I am interested in creating a website entirely in silverlight (personal reasons) but I
I have been going over the practicality of some of the new parallel features
I'm developing ASP.NET in C# after performing aspnet_regsql on my database. I want to
I have a Java program performing some large analysis tasks, running through a loop
Interested in writing an iPhone app but don't want to buy a mac or
Interested in people's opinion. You have an application server running 3/4 services that do
I'm wondering what you do as a programmer that's not programming but necessary for
I'm interested in performing feature extraction using C++ for medical images (i.e; malignant and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.