1

Possible Duplicates:
using mysql_close()
close mysql connection important?

What are the benefits of closing the connection using mysql_close() as the last line of your script compared to letting php close it for you?

Community
  • 1
  • 1
Hailwood
  • 89,623
  • 107
  • 270
  • 423

2 Answers2

2

None if you have it as the last line of the script.

You can improve performance by closing as soon as you are done so the handle is available for other processes to use.

This implies you are doing some other stuff after you are done with the db.

Byron Whitlock
  • 52,691
  • 28
  • 123
  • 168
0

None, using it before the end of script can free up one mysql connection and probably little Ram on php server.

But reopening connections to mysql is slow, so imho you'd better let php call it at end of execution, or use persistent connections.

Generally php scripts are run for milliseconds, even with good traffic hits, getting a high number (I mean 100+ at least) connections on mysql is rare. And again if this happens, use persistent connections.

Benoit
  • 3,569
  • 2
  • 22
  • 20