I am trying to decide whether to use MDB2 or PHP PDO. I am sort of leaning towards using PHP PDO at the moment, but I'd rather ask some experts on their opinion. Just fyi, I am using PHP 5.2.6-1+lenny3 and mySQL on a Linux server, I have created a table of about 20 fields and loaded 20,000 rows of data into the table. I then ran a select with a where clause and an update on every row, while testing performance of MDB2 and PHP PDO. I also tested whether a raw statement query to the server would be faster than forming a prepare statement and then executing using both MDB2 and PHP PDO.
In my tests I found that using raw statements in MDB2 and PHP PDO is faster than using a prepare statement and then executing it for each row (raw statement was much faster using MDB2 and only slightly faster using PHP PDO). To capture the times I issued a microtime() just before the query/execute and just after.
For processing 20,000 transactions:
Here are my results for the MDB2 raw Select php program:
- ran for 10.1 seconds vs 17.7 seconds for the prepare. The MDB2 raw update ran for 12.3 seconds vs 20.3 seconds for the MDB2 prepare.
Here are my results for the PDO raw
Select PHP program:
- ran for 8.3 seconds vs 8.3 seconds for the prepare. The PDO raw update ran for 5.78 seconds vs 5.92 seconds for the PDO prepare.
I have attached my code for review.
I was told that using a prepare is much faster then using raw sql but my test results prove otherwise. Why is the prepare and
execute method is slower than building the statement manually and
querying the server? Shouldn't the prepare and execute method be faster
since you only need to generate the prepare once as opposed to
generating the statements within a loop?
-Kevin
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php