note 22361 added to function.mysql-fetch-array
| From: | robjohnson at black-hole dot com | Date: | Fri, 14 Jun 2002 19:22:50 +0000 |
| Subject: | note 22361 added to function.mysql-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31871@lists.php.net to get a copy of this message | ||
Benchmark on a table with 38567 rows:
mysql_fetch_array
MYSQL_BOTH: 6.01940000057 secs
MYSQL_NUM: 3.22173595428 secs
MYSQL_ASSOC: 3.92950594425 secs
mysql_fetch_row: 2.35096800327 secs
mysql_fetch_assoc: 2.92349803448 secs
As you can see, it's twice as effecient to fetch either an array or a hash, rather than getting
both. it's even faster to use fetch_row rather than passing fetch_array MYSQL_NUM, or
fetch_assoc rather than fetch_array MYSQL_ASSOC. Don't fetch BOTH unless you really need them,
and most of the time you don't.
--
http://www.php.net/manual/en/function.mysql-fetch-array.php
http://master.php.net/manage/user-notes.php?action=edit+22361
http://master.php.net/manage/user-notes.php?action=delete+22361
http://master.php.net/manage/user-notes.php?action=reject+22361