Prev: Combing PDO with mysql_pconnect connections in one application --will this degrade performance?
Next: Combing PDO with mysql_pconnect connections in one application -- will this degrade performance?
From: Lester Caine on 10 Dec 2009 13:43 Sara Leavitt wrote: > So I can see that using two connections for updating might get out of > synch; however, mixing the connections should be OK for a series of > SELECT queries on the read-only side of the application, right? Yes - if you are only reading already stored data there should not be a problem. > -Sara > > Lester Caine wrote: >> Sara Leavitt wrote: >>> Hi Lester, >>> >>> Our application is not using php transactions (e.g., COMMIT, ROLLBACK >>> etc.), so I think we are safe there. Are you saying that even if >>> both the mysql_pconnect and PDO connection are persistent that they >>> will be completely separate? (Havn't had a chance to test this >>> empirically just yet.) >> >> Yes ... I'm not totally sure about how MySQL works by default, but >> having 'committed' data on one connection, one would need to refresh >> the other connection possibly to see that data. Firebird is a lot more >> manageable on transaction control, and basically data entered on on >> connection will not be visible on the other until properly committed. >> Having that activity hidden in the drivers can lead to a little >> 'confusion' as to what state data is actually in .... >> >> Even just opening two connections via the MySQL driver will have the >> same effect. -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php
From: Christopher Jones on 10 Dec 2009 14:47 Andy Shellam (Mailing Lists) wrote: > "First, when connecting, the function would first try to find a > (persistent) link that's already open with the same host, username > and password. If one is found, an identifier for it will be returned > instead of opening a new connection." > > Therefore, providing you've configured PHP's --with-mysql and > --with-pdo-mysql options with the same MySQL library, then as long > as the host, username and password are the same, the same connection > will be re-used for both the native (mysql_pconnect) connection and > the PDO connection. The doc refers to the PHP end of the connection and only to any existing PDO connection. PDO uses a hash table for open connections which it scans for matches when a PDO connection call is executed. The hash key is unique and begins with "PDO:DBH:DSN=". The mysql extension uses "mysql_" for its hash key prefix. This mean the PHP data structures for persistent connections won't be shared between the two extensions. Whether the MySQL client library or the MySQL database reuses any connection data underneath, I don't know. In Oracle the answer would be that PDO_OCI and OCI8 connections are distinct and transactionally separate (though they could share the same database connection pool if one was enabled). Chris -- Blog: http://blogs.oracle.com/opal Twitter: http://twitter.com/ghrd
From: Sara Leavitt on 10 Dec 2009 15:11 How about combining MySQLi with mysql_pconnect? Assuming both are persistent, would those connections be shared? The goal here is to use prepared statements. I read that MySQLi only supports persistent connections in php version 5.3 which we are not yet running, but perhaps it would be worth waiting for 5.3. -Sara Christopher Jones wrote: > > > Andy Shellam (Mailing Lists) wrote: > > "First, when connecting, the function would first try to find a > > (persistent) link that's already open with the same host, username > > and password. If one is found, an identifier for it will be returned > > instead of opening a new connection." > > > > Therefore, providing you've configured PHP's --with-mysql and > > --with-pdo-mysql options with the same MySQL library, then as long > > as the host, username and password are the same, the same connection > > will be re-used for both the native (mysql_pconnect) connection and > > the PDO connection. > > The doc refers to the PHP end of the connection and only to any > existing PDO connection. PDO uses a hash table for open connections > which it scans for matches when a PDO connection call is executed. > The hash key is unique and begins with "PDO:DBH:DSN=". The mysql > extension uses "mysql_" for its hash key prefix. This mean the PHP > data structures for persistent connections won't be shared between the > two extensions. > > Whether the MySQL client library or the MySQL database reuses any > connection data underneath, I don't know. In Oracle the answer would > be that PDO_OCI and OCI8 connections are distinct and transactionally > separate (though they could share the same database connection pool if > one was enabled). > > Chris >
From: Christopher Jones on 10 Dec 2009 16:02
Sara Leavitt wrote: > How about combining MySQLi with mysql_pconnect? Assuming both are > persistent, would those connections be shared? > The goal here is to use prepared statements. I read that MySQLi only > supports persistent connections in php version 5.3 which we are not yet > running, but perhaps it would be worth waiting for 5.3. > > -Sara The mysqli extension appears to use "mysqli_" as the hash key prefix so there won't be PHP connection structure sharing here either. Chris > > > Christopher Jones wrote: >> >> >> Andy Shellam (Mailing Lists) wrote: >> > "First, when connecting, the function would first try to find a >> > (persistent) link that's already open with the same host, username >> > and password. If one is found, an identifier for it will be returned >> > instead of opening a new connection." >> > >> > Therefore, providing you've configured PHP's --with-mysql and >> > --with-pdo-mysql options with the same MySQL library, then as long >> > as the host, username and password are the same, the same connection >> > will be re-used for both the native (mysql_pconnect) connection and >> > the PDO connection. >> >> The doc refers to the PHP end of the connection and only to any >> existing PDO connection. PDO uses a hash table for open connections >> which it scans for matches when a PDO connection call is executed. >> The hash key is unique and begins with "PDO:DBH:DSN=". The mysql >> extension uses "mysql_" for its hash key prefix. This mean the PHP >> data structures for persistent connections won't be shared between the >> two extensions. >> >> Whether the MySQL client library or the MySQL database reuses any >> connection data underneath, I don't know. In Oracle the answer would >> be that PDO_OCI and OCI8 connections are distinct and transactionally >> separate (though they could share the same database connection pool if >> one was enabled). >> >> Chris >> -- Blog: http://blogs.oracle.com/opal Twitter: http://twitter.com/ghrd |