mysql_fetch_assoc vs. mysql_fetch_array
Posted: Fri May 30, 2008 11:56 am
I always use mysql_fetch_array($result) when running a query. I was just wondering is there any advantage (ex: speed) using mysql_fetch_assoc instead?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
John Cartwright has obviously never seen a result set larger than 10 million rows, let alone 1 billion, and he'll have to be damned because there is definitely a speed difference on very large result sets and I am using speed as an argument for using one over the otherJohn Cartwright wrote:I'll be damned if anyone used speed as an argument in using on over another
Sorry to reply to this old topic. However, you would be mistaken in making that assumption. Reguardless, you have to be absolutely mad to be iterating a result set of 10 million rows.devhen wrote:mysql_fetch_assoc would be faster than mysql_fetch_array because mysql_fetch_array is populating numeric *and* associative arrays for each result. mysql_fetch_array($result, MYSQL_ASSOC) is equivalent to mysql_fetch_assoc. Furthermore, mysql_fetch_array($result, MYSQL_NUM) is the fastest because it is only populating a numeric array for each result. This makes it faster and uses less bandwidth.
John Cartwright has obviously never seen a result set larger than 10 million rows, let alone 1 billion, and he'll have to be damned because there is definitely a speed difference on very large result sets and I am using speed as an argument for using one over the otherJohn Cartwright wrote:I'll be damned if anyone used speed as an argument in using on over another