David Wheeler wrote:
On Sunday, November 24, 2002, at 01:08  PM, Bas A.Schulte wrote:

I'm wondering if I would gain (some) performance by preparing my sql statements once during ChildInit when using MySQL? Does it cache execution plans for sql statements? I know it makes a big difference on Oracle but I'm not sure what MySQL is like in this respect.

MySQL doesn't have a prepared statement feature, so you wouldn't get the same kind of performance gain that you would with Oracle. That said, DBD::mysql does a bit of munging with your statements, and if you use prepare(), it does that munging only once per statement.

The upshot: Use prepare() whenever possible to maximize performance. Even better, used prepare_cached() for statements you'll be using a lot, and then they'll be prepared only the first time prepare() is called (per Apache child). Doing so will also make it easier to gain the performance benefit if you later decide to switch to a database such as Oracle that supports prepared statements in the database.
What David said, plus your friendly docs:
http://perl.apache.org/search/swish.cgi?query=prepare_cached&sbm=SecE&submit=search

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Reply via email to