perf(query): increase speed of user queries (#7126) (#7128)

* perf(query): increase speed of user queries
This commit is contained in:
Silvan 2024-01-02 14:41:46 +01:00 committed by GitHub
parent cc2dd8b20b
commit a8b8c89f73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 4 deletions

View File

@ -23,8 +23,6 @@ WITH login_names AS (SELECT
(p.is_default IS TRUE AND p.instance_id = $2)
OR (p.instance_id = $2 AND p.resource_owner = u.resource_owner)
)
AND
u.id = $1
ORDER BY is_default
LIMIT 1
) p ON TRUE
@ -33,6 +31,9 @@ WITH login_names AS (SELECT
ON
u.instance_id = d.instance_id
AND u.resource_owner = d.resource_owner
WHERE
u.instance_id = $2
AND u.id = $1
)
SELECT
u.id

View File

@ -30,6 +30,12 @@ WITH found_users AS (
u.instance_id = d.instance_id
AND u.resource_owner = d.resource_owner
AND CASE WHEN p.must_be_domain THEN d.name_lower = $2 ELSE TRUE END
WHERE
u.instance_id = $4
AND u.user_name_lower IN (
$1,
$3
)
),
login_names AS (SELECT
fu.id user_id

View File

@ -24,8 +24,6 @@ WITH login_names AS (
(p.is_default IS TRUE AND p.instance_id = $2)
OR (p.instance_id = $2 AND p.resource_owner = u.resource_owner)
)
AND
u.id = $1
ORDER BY is_default
LIMIT 1
) p ON TRUE
@ -34,6 +32,9 @@ WITH login_names AS (
ON
u.instance_id = d.instance_id
AND u.resource_owner = d.resource_owner
WHERE
u.instance_id = $2
AND u.id = $1
)
SELECT
u.id

View File

@ -30,6 +30,12 @@ WITH found_users AS (
u.instance_id = d.instance_id
AND u.resource_owner = d.resource_owner
AND CASE WHEN p.must_be_domain THEN d.name_lower = $2 ELSE TRUE END
WHERE
u.instance_id = $4
AND u.user_name_lower IN (
$1,
$3
)
),
login_names AS (SELECT
fu.id user_id