470,619 Members | 2,033 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

mysql_pconnect() vs mysql_connect()

Coming from a java background, I've been taught that connection pooling is
the best thing due to the obvious benefits.

I found out that the above pconnect() function will pool connections.

So how do you use it properly? There's another post in this list stating
that the user got connection refused error messages.

Also, is there a real performance increase due to connection pooling with
MySQL in PHP?

Thanks,
- Z -
Jul 20 '05 #1
4 6340
"OneSolution" <on*********@sbcglobal.net> wrote in message news:ctnlc.6227
I found out that the above pconnect() function will pool connections.
Where is this function. I cannot find the string "pconnect" in all of my
c:\mysql\include, and I have version 4.1.
So how do you use it properly? There's another post in this list stating
that the user got connection refused error messages.

Also, is there a real performance increase due to connection pooling with
MySQL in PHP?


Don't know about your exact question, but have a response for a similar
setup on C++. I do the connection pooling on the C++ side (which is
probably slightly faster than doing the pooling on the MySql Server side) --
there is a class Database which has an array of used and unused connections,
and when a Select object needs a connection it requests one from Database,
which looks in its array of unused connections for one, and if it doesn't
find one creates a new ActualConnection with mysql_real_connect, and the
destructor of ActualConnection calls myql_close to close the connection, and
the destructor of Select gives its connection back to the databasee.

My test program was to select last_name and first_name from contact N=3000
times, and to iterate through all the rows and count the number of columns
in each row. First run is with the connection pooling as described above,
and second run is with no connection pooling which is accomplished by
calling the function database.close_unused_connections().

The connection pooling method took 3562 milliseconds, and the non connection
pooling method took 21781 milliseconds.

In my test we connect to localhost. The times would be longer if we
connected to a remotehost.

My setup is Borland C++ Builder version 6, Windows ME with 128 MB RAM, MySql
version 4.1, and an AMD 1 GHz processor.
Jul 20 '05 #2
"OneSolution" <on*********@sbcglobal.net> wrote in message news:ctnlc.6227
I found out that the above pconnect() function will pool connections.
Where is this function. I cannot find the string "pconnect" in all of my
c:\mysql\include, and I have version 4.1.
So how do you use it properly? There's another post in this list stating
that the user got connection refused error messages.

Also, is there a real performance increase due to connection pooling with
MySQL in PHP?


Don't know about your exact question, but have a response for a similar
setup on C++. I do the connection pooling on the C++ side (which is
probably slightly faster than doing the pooling on the MySql Server side) --
there is a class Database which has an array of used and unused connections,
and when a Select object needs a connection it requests one from Database,
which looks in its array of unused connections for one, and if it doesn't
find one creates a new ActualConnection with mysql_real_connect, and the
destructor of ActualConnection calls myql_close to close the connection, and
the destructor of Select gives its connection back to the databasee.

My test program was to select last_name and first_name from contact N=3000
times, and to iterate through all the rows and count the number of columns
in each row. First run is with the connection pooling as described above,
and second run is with no connection pooling which is accomplished by
calling the function database.close_unused_connections().

The connection pooling method took 3562 milliseconds, and the non connection
pooling method took 21781 milliseconds.

In my test we connect to localhost. The times would be longer if we
connected to a remotehost.

My setup is Borland C++ Builder version 6, Windows ME with 128 MB RAM, MySql
version 4.1, and an AMD 1 GHz processor.
Jul 20 '05 #3
OneSolution wrote:

: Coming from a java background, I've been taught that connection
: pooling is the best thing due to the obvious benefits.
:
: I found out that the above pconnect() function will pool connections.
:
: So how do you use it properly? There's another post in this list
: stating that the user got connection refused error messages.
:
: Also, is there a real performance increase due to connection pooling
: with MySQL in PHP?
:
: Thanks,
: - Z -
Hi
maybe these pages may be of use to you.
http://uk.php.net/function.mysql-pconnect
http://uk.php.net/manual/en/features...onnections.php
Jul 20 '05 #4
OneSolution wrote:

: Coming from a java background, I've been taught that connection
: pooling is the best thing due to the obvious benefits.
:
: I found out that the above pconnect() function will pool connections.
:
: So how do you use it properly? There's another post in this list
: stating that the user got connection refused error messages.
:
: Also, is there a real performance increase due to connection pooling
: with MySQL in PHP?
:
: Thanks,
: - Z -
Hi
maybe these pages may be of use to you.
http://uk.php.net/function.mysql-pconnect
http://uk.php.net/manual/en/features...onnections.php
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Yun Guan | last post: by
4 posts views Thread by Angelos | last post: by
19 posts views Thread by Michael | last post: by
1 post views Thread by tom_b | last post: by
1 post views Thread by WhatsPHP | last post: by
11 posts views Thread by =?ISO-8859-1?Q?J=F8rn?= Dahl-Stamnes | last post: by
9 posts views Thread by John Murtari | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.