Thursday 20 December 2007

Show database connections


 mysql> show full processlist;
+------+------+-----------------+-----------+---------+------+-------+-----------------------+
| Id | User | Host | db | Command | Time | State | Info |
+------+------+-----------------+-----------+---------+------+-------+-----------------------+
| 2191 | root | localhost:43821 | mysql | Query | 0 | NULL | show full processlist |
| 2776 | root | localhost | autocatch | Sleep | 195 | NULL | NULL |
| 2801 | root | localhost | autocatch | Sleep | 158 | NULL | NULL |
| 2864 | root | localhost | autocatch | Sleep | 125 | NULL | NULL |
| 2896 | root | localhost | autocatch | Sleep | 92 | NULL | NULL |
| 2914 | root | localhost | autocatch | Sleep | 59 | NULL | NULL |
| 2940 | root | localhost | autocatch | Sleep | 26 | NULL | NULL |
+------+------+-----------------+-----------+---------+------+-------+-----------------------+
7 rows in set (0.00 sec)

The 'Time' column shows a number of database connections staying open for upwards of 3 minutes, the numbers here are measured in seconds. This leads me to believe that somewhere in your website's code, connections are not being closed immediately after execution of the necessary queries.