Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql_result vs mysql_array_assoc

Tags:

php

Is there a performance difference between using mysql_result and mysql_array_assoc to loop through a large SQL select result?

like image 394
Brian Avatar asked Apr 08 '26 15:04

Brian


1 Answers

From the mysql_result() manual page:

When working on large result sets, you should consider using one of the functions that fetch an entire row (specified below). As these functions return the contents of multiple cells in one function call, they're MUCH quicker than mysql_result(). Also, note that specifying a numeric offset for the field argument is much quicker than specifying a fieldname or tablename.fieldname argument.

So it seems that mysql_array_assoc(), one of the functions that quote refers to, is going to be your best bet.

like image 149
zombat Avatar answered Apr 11 '26 05:04

zombat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!