0

Is there anyway I could keep the DBI session active even after the script exits?

http://mysqlresources.com/documentation/perl-dbi/connect

Basically I need to call the perl (DBI) script multiple times with different parameters (decide pass/fail after it completes). Each time its called Perl is making new connection to Mysql and destroys while exiting which itself is adding considerable amount of delay.

Just wondering if there is any way I could store and use the session for future?

Siva
  • 294
  • 1
  • 9
  • 25
  • I'm not sure if you're talking about a Perl web app or a console app. See http://stackoverflow.com/questions/3267591/perl-connection-pooling – Bill Karwin May 02 '14 at 19:55

1 Answers1

4

Your connection and its associated socket is process specific, so there's no way of keeping it alive after your process terminates.

You should be able to better tune your server so that connecting is faster. A common issue is doing a reverse IP lookup by enabling the skip-name-resolve configuration parameter in my.cnf.

Barring that, what you might do is use either MySQL Proxy to keep a pool of warm connections, or to combine all your various operations into a single script that can run several stages without terminating.

tadman
  • 208,517
  • 23
  • 234
  • 262