[clug] MySQL prepared statements issue

Tim Murphy tim at murphy.org
Thu Feb 14 03:53:04 GMT 2008

> Are you using the mysql command line tool or are you going through another
layer?  If the layer uses the one database 
> connection for all it's clients then they will all share the same scope.

It's all being run from an ASP script.  Basically it connects to the DB,
runs the PREPARE statement, disconnects.  Connects again, stores all the
variables, disconnects.  Connects, runs the EXECUTE statement, disconnects.

This sporadic connecting and disconnecting happens because all DB activity
is run through a function: connect, run query, gather data, disconnect.

> If I'm right you should be able to work around the problem by not
deallocating the prepared statement.  MySQL will
> automatically deallocate it when the session is closed.

I removed the DEALLOCATE query from the system but it didn't make much
difference.  I did notice, though, that the prepared_stmt_count hovered
around the 2 - 5 mark, as it did with the DEALLOCATE left in.

More information about the linux mailing list