Mysql veritabanından okuma zamanı Karmaşıklık

0 Cevap php

Ben bilmek istiyorum, thory hangi kod uzun sürer:

1..

$query = "SELECT Something1, Something2 FROM base WHERE SomeCondition";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
//We do something with $row[0] and row[1]
}

2.

$query = "SELECT Something1 FROM base WHERE SomeCondition";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
//We do something with $row[0]
}
$query = "SELECT Something2 FROM base WHERE SomeCondition";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
//We do something with $row[0]
}

Now 1.. should be faster, because while statment executes in O(n) time, while the other in O(2*n), but in the first one it has to query for two columns at once, where in 2. it has to to query for one column, but twice. Now I wonder how performance wise is the mysql_query and mysql_fetch_array on one column at once, or two columns at once?

0 Cevap