Gossamer Forum
Home : Products : Gossamer Links : Discussions :

persistent mysql connections

Quote Reply
persistent mysql connections
Hi there.

I'm using Links SQL in dynamic mode, cgi interface. I recently wrote a very simple sitewide traffic tracking script in PHP that I'm calling on each page through an image tag (not sure if that's the best way to do that, but it appears to be working). The PHP script is essentially just recording into a mysql database some basic information about the pageview.

At any rate, I'm trying to be efficient in my use of mysql connections. The PHP tracking script uses mysql_pconnect(), which, as I understand it, will only make a new connection if there isn't one currently open for the same host and user. My question is: does Links SQL use a persistent connection? I'm hoping it does, so I can make sure I'm not opening a new connection every time someone views a Links page, and then another when the PHP tracking script records its information. Two connections per page view seems a bit excessive.

Thanks in advance for any information or advice.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] persistent mysql connections In reply to
It only uses persistent connections under mod_perl when Apache::DBI is loaded. Otherwise a new connection is made on each request. The $DB object is cached for best performance though.
Quote Reply
Re: [Paul] persistent mysql connections In reply to
Excuse my ignorance, but what is the $DB object?

If I were running it in PHP mode, would I be able to use persistent connections?

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] persistent mysql connections In reply to
The $DB object is created by GT::SQL and is used for all database queries eg..

$DB->table('Links')->select;

Instead of creating a new object for every query the first object created is cached and can then be re-used if $DB->table('Links') is called again.

I can't help with your php question I'm afraid.
Quote Reply
Re: [Paul] persistent mysql connections In reply to
Cool, thanks. I guess I should ask the PHP question in the PHP forum... ;-)

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund