Low cost ecommerce web development India flash website design

Forego Buffering on Large Queries


For large queries (that is, queries that produce large result sets), you can
improve performance dramatically by telling PHP not to buffer the results
of the query. When a query is buffered, the entire result set is retrieved from
MySQL and stored in memory before your script is allowed to proceed

unbuffered query, on the other hand, lets MySQL hold onto the results
until you request them, one row at a time (e.g. with mysql_fetch_array).
Not only does this allow your script to continue running while MySQL performs
the query, it also saves PHP from having to store all of the rows in
memory at once.
PHP lets you perform unbuffered queries with mysql_unbuffered_query:
$queryResource = mysql_unbuffered_query($sql, $dbConn);
Of course, all good things come at a price—with unbuffered queries you can
no longer use the mysql_num_rows function to count the number of rows.
Obviously, as PHP doesn’t keep a copy of the complete result set, it is unable
to count the rows it contains! You also must fetch all rows in the result set
from MySQL before you can make another query.
Although other functions exist for getting rows and cells from query results, like
mysql_fetch_object and mysql_result, you can achieve more or less the same
things with just mysql_fetch_array, and the consistency may help keep your
code simple.

website designer freelance ASP PHP ecommerce web developer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110