-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use paginated search for contacts #18816
Conversation
6f5ba0d
to
c41a99b
Compare
c41a99b
to
043c013
Compare
@@ -68,8 +68,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) { | |||
$resultType = new SearchResultType('remotes'); | |||
|
|||
// Search in contacts | |||
//@todo Pagination missing | |||
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN']); | |||
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN'], ['limit' => $limit, 'offset' => $offset]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is, if you e.g. match the local domain, you will get all system address book entries.
But they are skipped with the first if
in the loop, but also no further contacts will be found, although you would have matches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contacts from other addressbooks should still be found, since the search is executed with the limit on each addressbook individually: https://github.com/nextcloud/server/pull/18816/files#diff-905974f5907f69fe7586a80ea67117a6L48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stil concerns @nickvergessen ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets try it
Needs a rebase |
043c013
to
8fd2031
Compare
Done. |
CI looks quite red |
8fd2031
to
17104b5
Compare
Signed-off-by: Julius Härtl <jus@bitgrid.net>
17104b5
to
6709833
Compare
Aw, isset is no function so using |
:( |
current syntaxSELECT `c`.`carddata`, `c`.`uri`
FROM `oc_cards` `c`
WHERE `c`.`id` IN (
SELECT DISTINCT `cp`.`cardid`
FROM `oc_cards_properties` `cp`
WHERE (`cp`.`addressbookid` = ?)
AND ((`cp`.`name` = ?)
OR (`cp`.`name` = ?))
AND (`cp`.`value` COLLATE utf8mb4_general_ci LIKE ?)
LIMIT 10
); SELECT `c`.`carddata`, `c`.`uri`
FROM `oc_cards` `c`
WHERE `c`.`id` IN (
SELECT `cardid` FROM (
SELECT DISTINCT `cp`.`cardid`
FROM `oc_cards_properties` `cp`
WHERE (`cp`.`addressbookid` = ?)
AND ((`cp`.`name` = ?)
OR (`cp`.`name` = ?))
AND (`cp`.`value` COLLATE utf8mb4_general_ci LIKE ?)
LIMIT 10
)
AS compatlayer
); |
This PR drastically improves the performance of searching for sharees when the system addressbook contains a lot of users. Without it all matching contact entries would be queried from the database for both SHARE_TYPE_REMOTE and SHARE_TYPE_EMAIL which led to quite bad performance when searching with queries that matched a lot of entries (1-3 characters)