Welcome Guest, Not a member yet? Register   Sign In
getUnbufferedRow() memory usage

Version 4.x

When using the getUnbufferedRow() for mysql results it seems that the driver does not properly apply the appropriate logic.

According to php docs, the default result mode is: MYSQLI_STORE_RESULT

When performing unbuffered queries you need to use MYSQLI_USE_RESULT while executing the query method.


A simple hack:

in file: /system/Database/MySQLi/Connection.php

Add property to class:  public $result_mode = MYSQLI_STORE_RESULT; // default

on line 329 in the execute method change:
return $this->connID->query($this->prepQuery($sql));
return $this->connID->query($this->prepQuery($sql),$this->result_mode);

Then in model when you need unbuffered results you can set result mode: $model->db->result_mode = MYSQLI_USE_RESULT;

I have a query when run in buffered mode consumes 300mb.

Then when I use getUnbufferedRow() it still consumes 100mb.

After applying the above hack and setting $model->db->result_mode = MYSQLI_USE_RESULT; it only consumes 5mb.

Perhaps there is a better fix than the one I outline above but this seems to make huge improvements in memory usage.

Theme © iAndrew 2016 - Forum software by © MyBB