I am using mod\_perl for my web application. Currently, I plan to use a mysql database across the network. In every CGI request to display\_customer\_transaction.cgi, my script will

1. Open up database connection across network
2. Perform query on the database using SQL statement
3. Analysis the data retrieved from database
4. Print out the data in HTML format
5. Close the database connection

After some profiling, I realize step (1) is the bottleneck. Hence, I wish to avoid opening and closing a database connection for every CGI request. My wish is, if my first CGI request opens up a database connection, my second incoming CGI request (from different client) may reuse the first database connection.

I tried to Google for "DBIX Persistent Database Connection" but hardly find relevant result. (Edit: that's because it's called DBIC, or DBIx::Class, not DBIX.)

I further find for relevant information, using [Apache::DBI](http://search.cpan.org/~abh/Apache-DBI/DBI.pm) (However, my intention is on DBIX, not Apache::DBI). There are some information which confused me:

> 
> The Apache::DBI module still has a limitation: it keeps database connections persistent on a per process basis.
> 
> 
> 

All the while, my concept on how Apache serving CGI request is that

1. Apache will always spawn a new process to serve an incoming new CGI request. Whenever the Perl interpreter finish executed Perl script, the process will dead.

So, if Apache::DBI module only able to keeps database connections persistent on a per process basis, how can my second CGI request re-use back the connection opened by the first CGI request?

But come back to my original question. How can I have DBIX persistent database connection in mod\_perl?