Craig Carper wrote:
> Mark Matthews wrote:
>
> ...
> > Nope. Not true. You can only have one open
> result
> > set per statement, but you can have as many
> open
> > statements on a connection as you need.
>
> Thanks for pointing out that multiple statements
> can co-exist on a connection. Habits can turn into
> false assumptions.
>
> Still, its not obvious how to use prepared
> statements to improve performance in a web
> application that grabs a connection for each
> request and isn't likely to execute the same
> statement twice in handling a single request.
> Seems a shame that a new connection can't benefit
> from an identical prepared statement on an earlier
> connection.
Craig,
In general, most (if not all) databases don't really allow you to fully "share" a prepared statement across connections. What you can do is use a connection pool that pools _statements_ though. Most "modern" ones have this functionality. In that way, the prepared statement that is pooled lives at least as long as the connection does, and can be reused multiple times by the application.
-Mark
Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html