Daevid Vincent wrote:
>> -----Original Message-----
>> From: Nathan Rixham [mailto:nrix...@gmail.com] 
>>
>> you'll also find a performance upgrade if you load all sql 
>> results in to
>> an array and close up the query / free the results before 
>> working on them.
>>
>> query
>> for() {
>>   $results[] = $row;
>> }
>> close stuff
>> work on results
> 
> Do you have any proof of this? 
> What would be the logic here? 
> Got some example benchmarks?
> Got a URL of a whitepaper or something that discusses this?
> 
> I would think the only things that the mysql calls are doing is holding
> pointers to the next record and DB handle. I can't imagine they are using
> that much resources, nor would they be just spinning and waiting tying up
> CPU cycles either.
> 
> 
> I've never heard this to be the case.
> 

I have proof to the contrary :-)

<?php
echo number_format(memory_get_usage()) . " Bytes used before query\n";

$conn = mysql_connect('localhost', 'x', 'x');
$result = mysql_query("SELECT * FROM table_name");
$count = mysql_num_rows($result);

echo $count . " rows returned\n";

echo number_format(memory_get_usage()) . " Bytes used after query\n";

while($rows[] = mysql_fetch_assoc($result)) { }

echo number_format(memory_get_usage()) . " Bytes used after array
creation\n";

mysql_free_result($result);

echo number_format(memory_get_usage()) . " Bytes used after
mysql_free_result\n";
?>

65,588 Bytes used before query
6940 rows returned
67,264 Bytes used after query
6,376,612 Bytes used after array creation
6,376,756 Bytes used after mysql_free_result

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to