Unless we do a mysql_unbuffered_query, mysql_query always put query results somewhere in server’s memory. I was looking at the code in DB_result.php and notice that it always copy the result set to an array. By this way, isn’t it duplicating the data in memory?
I think CI uses this approach because the arrays are the only way to send data to the views. Or not? But think about a very large result set. Why we need to have two copies of it in memory (array and buffer), if we already have copied it to an array? Shouldn’t the functions that fetch data to arrays automatically free the results from the buffer, as they will not be needed anymore? Or CI does this already?
In my own library, I never retrieve result sets to arrays as I always direct them to where they was needed. For example, after fetching a row, I forward each field to my own template parser. Well, I agree that this may not be the perfect way to separate application logic from presentation logic, because the loops goes with the application. But in this case, I never needed to make copies of the result sets to arrays. But with Code Igniter I think this is not possible, unless if have a way to place a function that act like mysql_fetch_array() into the views.
Well, I new here and I want to know what is the best way to do the things. Don’t this copy of result sets to arrays affect the server performance anyhow? Or are they absolute necessary to use all the power or Code Igniter?
