mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 17:27:31 +00:00

# Which Problems Are Solved
When an organization domain is verified, e.g. also when creating a new
organization (incl. generated domain), existing usernames are checked if
the domain has been claimed.
The query was not optimized for instances with many users and
organizations.
# How the Problems Are Solved
- Replace the query, which was searching over the users projection with
(computed loginnames) with a dedicated query checking the loginnames
projection directly.
- All occurrences have been updated to use the new query.
# Additional Changes
None
# Additional Context
- reported through support
- requires backport to v3.x
(cherry picked from commit fefeaea56a
)
13 lines
602 B
SQL
13 lines
602 B
SQL
SELECT u.id
|
|
FROM projections.login_names3_users u
|
|
LEFT JOIN projections.login_names3_policies p_custom
|
|
ON u.instance_id = p_custom.instance_id
|
|
AND p_custom.instance_id = $1
|
|
AND p_custom.resource_owner = u.resource_owner
|
|
JOIN projections.login_names3_policies p_default
|
|
ON u.instance_id = p_default.instance_id
|
|
AND p_default.instance_id = $1 AND p_default.is_default IS TRUE
|
|
WHERE u.instance_id = $1
|
|
AND COALESCE(p_custom.must_be_domain, p_default.must_be_domain) = false
|
|
AND u.user_name_lower like $2
|
|
AND u.resource_owner <> $3; |