I am using PHP to query the MySQL database on my website. Please answer the following questions:
- What will happen if I don't use
mysql_close()
when I am done with querying the database in the end? The connection will remain open? If yes then upto how much time? If no then why? - If I open and close a connection to MySQL at several places in a webpage, how is the performance affected? i.e. connection is made again everytime some access to database is required on a single webpage.
- How is
mysql_close()
related to performance? Should I open a new connection everytime some access to database is required OR should I keep only one connection and close it in the end? - If I don't close the connection, then if the user is trying to access some data again, will the new connection be used or the old open connection will be used?