summaryrefslogtreecommitdiff
path: root/plugins/kolab_addressbook
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-11-23 10:16:21 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-11-23 10:16:21 (GMT)
commitf97e1b53098941ec4cd52ec1704d7a945bd65a12 (patch)
tree3491864f814ae9550f38e220be2ab1bb5924d12d /plugins/kolab_addressbook
parentfb4f815e532aebed80bfba806621e61322faaf4c (diff)
downloadroundcubemail-plugins-kolab-f97e1b53098941ec4cd52ec1704d7a945bd65a12.tar.gz
Performance: skip SELECT COUNT(*) query in case when result contains less records than page size
Diffstat (limited to 'plugins/kolab_addressbook')
-rw-r--r--plugins/kolab_addressbook/lib/rcube_kolab_contacts.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
index 3b4a3f6..fa21583 100644
--- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
+++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
@@ -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));
}