Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
June 30, 2006, 3:52 pm
rate this thread
When doing mysql query (SELECT statements) in php, we often use prepare
statement to prevent SQL injection. However, I just noticed that the
prepare statements can SLOW the number of queries per second by a
factor of 2 times (max).
So are there any faster method that can prevent SQL injection, but has
a better performance?
Re: MySQL prepare statement performance bottom-neck
If it is MySQL < 4.1, then you are using emulated prepared statements,
which may be causing the slowdown. It wouldn't surprise me if PEAR was
doing some funny regex's to parse the queries, escape the values, etc.
If you're using a database abstraction library, maybe try switching the
abstraction library (See PDO and Adodb, among others), it might speed
It should also be noted that using prepare/execute requires 2 trips to
since it has to send it to be parsed, then send it to be executed.
This would account for the exact factor of 2.