Home > Dedicated Server, MySQL > What is the advantge and disadvantage of mysql_connect() and mysql_pconnect() ?

What is the advantge and disadvantage of mysql_connect() and mysql_pconnect() ?

April 16th, 2009 Leave a comment Go to comments

mysql_pconnect() will maintain a persistent connection to the database. Whenever your script calls the connect to database function, it first searches already existing connections to the database and if exists it will use the same connection to connect to the database, if not it will open a new connection to the database. ie. Connection is Persistent

where as mysql_connect() function will establish a new connection whenever a connection to database needed, and after executing the script, this function disconnects the connection. ie. connection is not a persistent one.

mysql_pconnect() function is used where your site has a Heavy Traffic and where as mysql_connect() function is used when there is moderate/less traffic to your site.

Regard’s

Alex P

System Administrator.

  1. August 3rd, 2010 at 02:49 | #1

    Thank you for useful info. :-)

  2. Anand
    April 5th, 2012 at 20:47 | #2

    Wow what a best explanation…

    Glad to see that …

    Thanks

    Alex P

  1. March 30th, 2010 at 09:24 | #1