1

i am using a perl script which inserts records into the database at every 5 minutes. Now when there is a lot of data available it might possible that number of connections made to the database increase thereby wasting my precious resources. So i want connection pooling mechanism to work with perl. I am using postgresql as my database. I googled it and i found some solutions like i found such solutions but they didnot work for me

Can anyone please tell me how can i achieve connection pooling in perl?

Thanks in advance.

7
  • You can also maintain persistent connection if so frequently used. Commented Jun 19, 2012 at 18:08
  • 1
    The stuff from the link you posted only works if you have mod_perl in use. If you use a cronjob (assumption) to insert data every 5 minutes, why does the number of connections increase? Is there so much data that 5 minutes isn't enough? If so, think about not starting the script as long as it is still running. Let it finish the first batch, then start with the next one. Commented Jun 19, 2012 at 18:08
  • @vjshah : that's what i am asking. i don't know how to do it. Commented Jun 19, 2012 at 18:27
  • @simbabque : i am not executing it as a cronjob. i am calling it as my wish. each time the script is called the connection will be created and after execution it will be released but it might possible that at a time there are hundreds instances of script running simultaneously so i want to implement an effective connection pooling mechanism which restrict the number of connections made to the database. Commented Jun 19, 2012 at 18:29
  • I'm fairly certain you cannot share a DBI instance/dbh between different processes. You might be able to realize it with a fork, though. Have a look at stackoverflow.com/questions/874434/…. Still it's interesting that it takes so long. Maybe there is a way to optimize it so it runs faster? Commented Jun 19, 2012 at 18:33

1 Answer 1

2

I'm not sure I'd restrict myself to a perl solution. Just install pgbouncer and have it available to any clients you require.

Sign up to request clarification or add additional context in comments.

2 Comments

what about MySQL?
The question isn't about MySQL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.