SQL Prepared Statements

I have not used prepared statements before, this looks like a great feature for repetitive queries.

MySQL :: Prepared Statements

So in pseudo code:

prepare sql
do
     set parameter(s)
     execute
     actions….
done
release

Did this on a fairly involved php page and quite honestly the data was inconclusive at best:

CASE              Queries    Run 1    Run 2     Run 3
Baseline            4013       41s        42s         42s
Prepare             5019       41s        40s         39s
More Optimize   4019       42s        40s         40s

I think it helped but it really went to show that the SQL part of the page was not making that much difference (this had one major table with about 42,000 rows)

This was done on a VM test server platform(linux) from the host os as the browser (Mac).  Before Run 1 each time I restarted both Apache & MySQL to eliminate the possibility of caching effects.

Leave a Reply