--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
<div class=3D"gmail_quote">Hello all,<br>
<br>
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. <br><br>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.<br><br><p style=3D"colo=
r: rgb(0, 0, 0);"><font size=3D"2" face=3D"Arial"><span style=3D"font-size:=
10pt; font-family: Arial;">For processing 20,000 transactions:</span></fon=
t></p>
<p style=3D"color: rgb(0, 0, 0);"><font size=3D"2" face=3D"Arial"><span sty=
le=3D"font-size: 10pt; font-family: Arial;">Here are </span></font><font si=
ze=3D"2" face=3D"Arial"><span style=3D"font-size: 10pt; font-family: Arial;=
">m</span></font><font size=3D"2" face=3D"Arial"><span style=3D"font-size: =
10pt; font-family: Arial;">y results for the </span></font><font size=3D"2"=
face=3D"Arial"><span style=3D"font-size: 10pt; font-family: Arial;">MDB</s=
pan></font><font size=3D"2" face=3D"Arial"><span style=3D"font-size: 10pt; =
font-family: Arial;">2 raw Select php program</span></font><font size=3D"2"=
face=3D"Arial"><span style=3D"font-size: 10pt; font-family: Arial;"></span=
></font><font size=3D"2" face=3D"Arial"><span style=3D"font-size: 10pt; fon=
t-family: Arial;">:</span></font></p>
<p style=3D"color: rgb(0, 0, 0);"><font size=3D"2" face=3D"Arial"><span sty=
le=3D"font-size: 10pt; font-family: Arial;">-=A0 ran for
10.1 seconds vs 17.7 seconds for the prepare. The </span></font><font size=
=3D"2" face=3D"Arial"><span style=3D"font-size: 10pt; font-family: Arial;">=
MDB</span></font><font size=3D"2" face=3D"Arial"><span style=3D"font-size: =
10pt; font-family: Arial;">2 raw update ran for 12.3 seconds vs 20.3 second=
s for the </span></font><font size=3D"2" face=3D"Arial"><span style=3D"font=
-size: 10pt; font-family: Arial;">MDB</span></font><font size=3D"2" face=3D=
"Arial"><span style=3D"font-size: 10pt; font-family: Arial;">2 prepare.</sp=
an></font></p>
<p style=3D"color: rgb(0, 0, 0);"><font size=3D"2" face=3D"Arial"><span sty=
le=3D"font-size: 10pt; font-family: Arial;">Here are </span></font><font si=
ze=3D"2" face=3D"Arial"><span style=3D"font-size: 10pt; font-family: Arial;=
">m</span></font><font size=3D"2" face=3D"Arial"><span style=3D"font-size: =
10pt; font-family: Arial;">y results for the PDO raw
Select PHP program: <br></span></font></p><p style=3D"color: rgb(0, 0, 0);"=
><font size=3D"2" face=3D"Arial"><span style=3D"font-size: 10pt; font-famil=
y: Arial;">- </span></font><font size=3D"2" face=3D"Arial"><span style=3D"f=
ont-size: 10pt; font-family: Arial;">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 </span></font><font=
size=3D"2" face=3D"Arial"><span style=3D"font-size: 10pt; font-family: Ari=
al;">prepare.</span></font></p>
<p style=3D"color: rgb(0, 0, 0);"><font size=3D"2" face=3D"Arial"><span sty=
le=3D"font-size: 10pt; font-family: Arial;">I have attached </span></font><=
font size=3D"2" face=3D"Arial"><span style=3D"font-size: 10pt; font-family:=
Arial;">m</span></font><font size=3D"2" face=3D"Arial"><span style=3D"font=
-size: 10pt; font-family: Arial;">y code for review.</span></font><font siz=
e=3D"2" face=3D"Arial"><span style=3D"font-size: 10pt; font-family: Arial;"=
><br>
</span></font></p>
<p><font style=3D"color: rgb(0, 0, 0);" size=3D"3" face=3D"Times New Roman"=
><span style=3D"font-size: 12pt;"><b><i><span style=3D"font-weight: bold; f=
ont-style: italic;"></span></i></b></span></font><b style=3D"color: rgb(0, =
0, 0);"><i><span style=3D"font-weight: bold; font-style: italic;"></span></=
i></b><font style=3D"color: rgb(0, 0, 0);" color=3D"blue">I was told that u=
sing a prepare is </font><font style=3D"color: rgb(0, 0, 0);" color=3D"blue=
">m</font><font style=3D"color: rgb(0, 0, 0);" color=3D"blue">uch faster th=
en using raw sql but </font><font style=3D"color: rgb(0, 0, 0);" color=3D"b=
lue">m</font><font style=3D"color: rgb(0, 0, 0);" color=3D"blue">y test res=
ults prove otherwise. </font><span style=3D"color: rgb(0, 0, 0);">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?</span><br></p>
<br>-Kevin<br>
</div>
--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--
