Welcome Guest, Not a member yet? Register   Sign In
First call to $query->next_row() loads all results
#1

[eluser]BlueCamel[/eluser]
I've found that using the mysqli or mysql driver, that the $query->next_row() call loads all results from the db. This isn't desirable with large result sets as it consumes memory. For example, with a result set of 4.2 million records, there doesn't appear to be a good way to iterate over them without loading them all.

Code:
$this->db->from($large_table);
$query = $this->db->get();
if (!$query) show_error('Failed DB query');

while ($row = $query->next_row())
{
    // the above next_row() call loaded all results as seen when dumping the $query object
    print_r($query);
    break;
}

$query->free_results();

How would you loop through a large result set advancing the cursor without loading the entire set into memory?


Messages In This Thread
First call to $query->next_row() loads all results - by El Forum - 03-07-2010, 10:28 AM
First call to $query->next_row() loads all results - by El Forum - 03-07-2010, 10:56 AM
First call to $query->next_row() loads all results - by El Forum - 03-07-2010, 11:19 AM
First call to $query->next_row() loads all results - by El Forum - 03-07-2010, 11:35 AM
First call to $query->next_row() loads all results - by El Forum - 03-07-2010, 11:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB