Skip to content
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

Missing index for guest display name lookup #1182

Open
ChristophWurst opened this issue Jun 20, 2024 · 0 comments
Open

Missing index for guest display name lookup #1182

ChristophWurst opened this issue Jun 20, 2024 · 0 comments
Labels
bug Something isn't working performances Performances issues and optimisations

Comments

@ChristophWurst
Copy link
Member

guests/lib/UserBackend.php

Lines 220 to 234 in ff10aed

$query->select('uid', 'displayname')
->from('guests_users', 'u')
->leftJoin('u', 'preferences', 'p', $query->expr()->andX(
$query->expr()->eq('userid', 'uid'),
$query->expr()->eq('appid', $query->expr()->literal('settings')),
$query->expr()->eq('configkey', $query->expr()->literal('email')))
)
// sqlite doesn't like re-using a single named parameter here
->where($query->expr()->iLike('uid', $query->createPositionalParameter('%' . $this->dbConn->escapeLikeParameter($search) . '%')))
->orWhere($query->expr()->iLike('displayname', $query->createPositionalParameter('%' . $this->dbConn->escapeLikeParameter($search) . '%')))
->orWhere($query->expr()->iLike('configvalue', $query->createPositionalParameter('%' . $this->dbConn->escapeLikeParameter($search) . '%')))
->orderBy($query->func()->lower('displayname'), 'ASC')
->orderBy('uid_lower', 'ASC')
->setMaxResults($limit)
->setFirstResult($offset);
does builds the query

SELECT
  `uid`,
  `displayname`
FROM
  `oc_guests_users` `u`
  LEFT JOIN `oc_preferences` `p` ON (`userid` = `uid`)
  AND (`appid` = ?)
  AND (`configkey` = ?)
WHERE
  (`uid` COLLATE `utf8mb4_general_ci` LIKE ?)
  OR (
    `displayname` COLLATE `utf8mb4_general_ci` LIKE ?
  )
  OR (
    `configvalue` COLLATE `utf8mb4_general_ci` LIKE ?
  )
ORDER BY
  `uid_lower` ASC
LIMIT
  ?

that does not use any index.

Query hash is d9703f573d96020de3765fcd7a85e628

@ChristophWurst ChristophWurst added bug Something isn't working performances Performances issues and optimisations labels Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working performances Performances issues and optimisations
Projects
None yet
Development

No branches or pull requests

1 participant