mysql_unbuffered_query(query[, link_id[, result_mode]])
This function sends an SQL query to MySQL, without fetching or buffering the result rows automatically, as mysql_query and mysql_db_query do. This method has two advantages: PHP does not need to allocate a large memory buffer to store the entire result set, and you can begin to process the results as soon as PHP receives the first row, instead of having to wait for the full result set to be received.
The down side is that functions that require information about the full result set (such as mysql_num_rows) are not available for result sets produced by mysql_unbuffered_query, and you must use mysql_fetch_* functions to retrieve all of the rows in the result set before you can send another query using that MySQL connection.