Forum Moderators: coopster

Message Too Old, No Replies

Mysql Results

Trying to optimize the way I handle large result sets

         

lobo235

9:20 pm on Jun 27, 2005 (gmt 0)

10+ Year Member



Hello all, I am trying to optimize the way I handle large result sets from MySQL. I have tried using both mysql_fetch_object() and mysql_fetch_assoc() to build multi-dimensional arrays of the database results. Both seem to work well but I am wondering what everyone on the forum uses and why? I prefer to deal with arrays myself even though I have used both.

sned

9:26 pm on Jun 27, 2005 (gmt 0)

10+ Year Member



I like to use mysql_fetch_object, don't really have a reason why, except maybe because I can use the result in strings ....

"blah blah blah $row->field etc etc etc ..."

-sned

mcibor

9:54 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are at least four ways of fetching results.
mysql_fetch_array(), mysql_fetch_assoc(), mysql_fetch_row() and mysql_fetch_object()

One of them is for sure faster than the other. As I recall Ergophobe is quite knowleadgable in computing speed.
However in my opinion the problem lies not in speed, as that is mostly slowed by mysql, not php, but in memory consumption.

The most consuming is object, then array then assoc and the least memory consuming is mysql_fetch_row.

Ask ergophobe with sticky mail, or just wait for an answer you like.

PS. You're really sure you need to handle such big results? There may be a better way.

wener

4:07 am on Jul 5, 2005 (gmt 0)

10+ Year Member



PS. You're really sure you need to handle such big results? There may be a better way.

Recently I am working on a site using php and mysql. I want to know how big the result is too big. Can you let me know? Thanks.

jatar_k

4:19 pm on Jul 5, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> how big the result is too big

the second you pull one row that you don't need on the page making the query