Make SQL selects less expensive in memory for some cases where we fetch big data chunks

pull/5268/merge
Aleksander Machniak 8 years ago
parent b9b4acb013
commit c478536741

@ -308,6 +308,8 @@ class rcube_cache
$data = $this->unserialize($sql_arr['data']); $data = $this->unserialize($sql_arr['data']);
} }
$this->db->reset();
if ($nostore) { if ($nostore) {
return $data; return $data;
} }

@ -302,6 +302,8 @@ class rcube_cache_shared
$data = $this->unserialize($sql_arr['data']); $data = $this->unserialize($sql_arr['data']);
} }
$this->db->reset();
if ($nostore) { if ($nostore) {
return $data; return $data;
} }

@ -773,6 +773,16 @@ class rcube_db
return $this->last_result = $this->dbh->rollBack(); return $this->last_result = $this->dbh->rollBack();
} }
/**
* Release resources related to the last query result.
* When we know we don't need to access the last query result we can destroy it
* and release memory. Usefull especially if the query returned big chunk of data.
*/
public function reset()
{
$this->last_result = null;
}
/** /**
* Formats input so it can be safely used in a query * Formats input so it can be safely used in a query
* *

@ -353,6 +353,8 @@ class rcube_imap_cache
} }
} }
$this->db->reset();
$msgs = array_flip($msgs); $msgs = array_flip($msgs);
} }

@ -106,6 +106,8 @@ class rcube_session_db extends rcube_session
$this->vars = base64_decode($sql_arr['vars']); $this->vars = base64_decode($sql_arr['vars']);
$this->key = $key; $this->key = $key;
$this->db->reset();
return !empty($this->vars) ? (string) $this->vars : ''; return !empty($this->vars) ? (string) $this->vars : '';
} }

Loading…
Cancel
Save