Re: database connections

From: NSpam (NoSpam_at_NoSpam.garbage.rubbish)
Date: 03/02/05


Date: Wed, 02 Mar 2005 16:02:04 GMT

Tim wrote:
> With a pconnect mysql holds a session so that you are not reconnecting
> each time. This works good if you are only connecting to one
> database.
>
> Warning:
> There are time when pulling information from two different databases
> within the same script where mysql will use the same session and try to
> pull them all from one table.
>
>
Hi Tim,

Interesting.

Do you know of a decent source of information regarding MySQL database
handles and sessions, particularly with regard to persistent
connections. I'm passing database handles around in sessions and see a
perceptable performance increase, in that i'm hacking existing code from:-

(pseudo code)

{
        // existing inherited code
        // brute force always get new connection
        connect to mysql database
        select database
        use new handle to database
}

to

{
        if (! isset($_SESSION['dbHandle'])) {
                connect to mysql database
                select database
                store handle to handle to database
        }
        else {
                use existing database handle
        }
}

As I say its perceptably quicker, 'cos I assume the database connection
is persisting. I'm just curious to know the nuts and bolts - any pointers ?

Cheers



Relevant Pages

  • Re: Credit card confirmation?
    ... MySQL was a very simple database before it incorporated the INNODB engine. ... It will obviously be SSL and the session ID etc will ... PHP stores the session when your script ends. ...
    (php.general)
  • Re: [PHP] A no brainer...
    ... The entire session needs to be de-serialized, not just some portion of it. ... The database is optimized for returning subsets of all the data. ... I know that goes against what you're saying, but there are some examples if you Google "PHP MySQL session performance". ... very complex query with lots of joins and subqueries, ...
    (php.general)
  • gzip: stdout: Broken pipe
    ... I am experiencing a weird issue with dbi while connecting to mysql ... system and feed the existence of chapter information to mysql database. ... gzip: compressed data not read from a terminal. ...
    (perl.dbi.users)
  • Re: Creating a database with MySQLTcl
    ... MySQL uses the database mysql as it's system database. ... Connecting to a db server doesn't require a database name, ...
    (comp.lang.tcl)
  • Re: Query 2 MySQL databases in 1 statement
    ... My concern is, when connecting to MySQL (or sending a query), I only ... the database you specify when connecting to mysql ...
    (comp.lang.php)