Performance: skip SELECT COUNT(*) query in case when result contains less records than page size
This commit is contained in:
parent
fb4f815e53
commit
f97e1b5309
1 changed files with 8 additions and 1 deletions
|
@ -365,7 +365,14 @@ class rcube_kolab_contacts extends rcube_addressbook
|
|||
}
|
||||
}
|
||||
else if (isset($this->dataset)) {
|
||||
$this->result->count = isset($query) ? $this->storagefolder->count($query) : 0;
|
||||
// get all records count, skip the query if possible
|
||||
if (!isset($query) || count($this->dataset) < $this->page_size) {
|
||||
$this->result->count = count($this->dataset) + $this->page_size * ($this->list_page - 1);
|
||||
}
|
||||
else {
|
||||
$this->result->count = $this->storagefolder->count($query);
|
||||
}
|
||||
|
||||
foreach ($this->dataset as $idx => $record) {
|
||||
$this->result->add($this->_to_rcube_contact($record));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue