plugins/kolab_addressbook
Aleksander Machniak
machniak at kolabsys.com
Sun Nov 23 11:17:01 CET 2014
plugins/kolab_addressbook/lib/rcube_kolab_contacts.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
New commits:
commit f97e1b53098941ec4cd52ec1704d7a945bd65a12
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Sun Nov 23 05:16:21 2014 -0500
Performance: skip SELECT COUNT(*) query in case when result contains less records than page size
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));
}
More information about the commits
mailing list