Trying to decide between MDB2 and PHP PDO
am 25.06.2009 18:09:28 von Kevin Castiglia--0016e6dbea5bca5a74046d2e7240
Content-Type: multipart/alternative; boundary=0016e6dbea5bca5a6d046d2e723e
--0016e6dbea5bca5a6d046d2e723e
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hello all,
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
--0016e6dbea5bca5a6d046d2e723e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
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 MDB=
2 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 MDB=
2 and
only slightly faster using PHP PDO). To capture the times I issued a microt=
ime() just before the query/execute and just after.
r: rgb(0, 0, 0);"> 10pt; font-family: Arial;">For processing 20,000 transactions: t>
le=3D"font-size: 10pt; font-family: Arial;">Here are ze=3D"2" face=3D"Arial"> ">m
10pt; font-family: Arial;">y results for the face=3D"Arial">MDB pan> font-family: Arial;">2 raw Select php program face=3D"Arial"> > t-family: Arial;">:
le=3D"font-size: 10pt; font-family: Arial;">-=A0 ran for
10.1 seconds vs 17.7 seconds for the prepare. The
=3D"2" face=3D"Arial">=
MDB
10pt; font-family: Arial;">2 raw update ran for 12.3 seconds vs 20.3 second=
s for the
-size: 10pt; font-family: Arial;">MDB
"Arial">2 prepare.
an>
le=3D"font-size: 10pt; font-family: Arial;">Here are
ze=3D"2" face=3D"Arial">
">m
10pt; font-family: Arial;">y results for the PDO raw
Select PHP program:
the prepare. The PDO raw
update ran for 5.78 seconds vs 5.92 seconds for the PDO size=3D"2" face=3D"Arial"> al;">prepare.
le=3D"font-size: 10pt; font-family: Arial;">I have attached <=
font size=3D"2" face=3D"Arial">
Arial;">m
-size: 10pt; font-family: Arial;">y code for review.
e=3D"2" face=3D"Arial">
>
>
ont-style: italic;">
0, 0);">=
i>I was told that u=
sing a prepare is
">much faster th=
en using raw sql but
lue">my test res=
ults prove otherwise. Why is th=
e 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
--0016e6dbea5bca5a6d046d2e723e--
--0016e6dbea5bca5a74046d2e7240
Content-Type: text/plain; charset=us-ascii
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--0016e6dbea5bca5a74046d2e7240--