zitadel/internal/query
Tim Möhlmann 3af28d29d2
fix(query): optimize instance by domain query (#7513)
fix(query): optimize instance by domain query

On zitadel cloud we noticed an increase in database CPU usage and slightly higher response times.
By analyzes we found that the instance by domain query was wrongly joining all instance_feature rows against all instances.
This PR adds an additional CTE to limit the join set to only the features that apply to the found instance.

The query was introduced with https://github.com/zitadel/zitadel/pull/7356 and part of the v2.47 release.
2024-03-06 18:02:16 +00:00
..
embed perf: user grant owner removed (#6962) 2024-01-08 15:26:30 +00:00
projection fix: assign instance ID to aggregate ID when converting from v1 to v2 feature (#7505) 2024-03-05 16:12:49 +01:00
testdata fix(oidc): return clients without instance settings (#7036) 2023-12-07 09:43:45 +00:00
access_token.go fix(api): handle user disabling events correctly in session API (#7380) 2024-02-28 09:30:05 +00:00
action_flow_test.go perf: remove owner removed columns from projections for oidc (#6925) 2023-11-20 17:21:08 +02:00
action_flow.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
action_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
action.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
app_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
app.go fix: uniform oidc errors (#7237) 2024-01-18 07:10:49 +01:00
auth_request_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
auth_request.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
authn_key_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
authn_key.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
certificate_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
certificate.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
converter.go feat(api): feature flags (#7356) 2024-02-28 10:55:54 +02:00
current_state_test.go feat(eventstore): increase parallel write capabilities (#5940) 2023-10-19 12:19:10 +02:00
current_state.go fix(db): always use begin tx (#7142) 2024-01-04 16:12:20 +00:00
custom_text_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
custom_text.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
device_auth_model.go feat(oidc): id token for device authorization (#7088) 2023-12-20 13:21:08 +01:00
device_auth_test.go feat(oidc): id token for device authorization (#7088) 2023-12-20 13:21:08 +01:00
device_auth.go feat(oidc): id token for device authorization (#7088) 2023-12-20 13:21:08 +01:00
domain_policy_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
domain_policy.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
event.go feat: block instances (#7129) 2024-01-17 10:16:48 +00:00
failed_events_test.go feat(eventstore): increase parallel write capabilities (#5940) 2023-10-19 12:19:10 +02:00
failed_events.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
iam_member_test.go perf(oidc): optimize client verification (#6999) 2023-12-05 17:01:03 +00:00
iam_member.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
idp_login_policy_link_test.go feat(storage): read only transactions for queries (#6415) 2023-08-22 10:49:22 +00:00
idp_login_policy_link.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
idp_template_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
idp_template.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
idp_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
idp_user_link_test.go feat(storage): read only transactions for queries (#6415) 2023-08-22 10:49:22 +00:00
idp_user_link.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
idp.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
instance_by_domain.sql fix(query): optimize instance by domain query (#7513) 2024-03-06 18:02:16 +00:00
instance_by_id.sql fix: assign instance ID to aggregate ID when converting from v1 to v2 feature (#7505) 2024-03-05 16:12:49 +01:00
instance_domain_test.go feat(storage): read only transactions for queries (#6415) 2023-08-22 10:49:22 +00:00
instance_domain.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
instance_features_model.go fix: assign instance ID to aggregate ID when converting from v1 to v2 feature (#7505) 2024-03-05 16:12:49 +01:00
instance_features_test.go feat(api): feature flags (#7356) 2024-02-28 10:55:54 +02:00
instance_features.go feat(api): feature flags (#7356) 2024-02-28 10:55:54 +02:00
instance_test.go feat(api): feature flags (#7356) 2024-02-28 10:55:54 +02:00
instance.go feat: improve instance not found error (#7413) 2024-02-28 10:49:57 +00:00
introspection_test.go perf(oidc): optimize the introspection endpoint (#6909) 2023-11-21 13:11:38 +01:00
introspection.go perf(oidc): optimize the introspection endpoint (#6909) 2023-11-21 13:11:38 +01:00
key_test.go fix(oidc): ignore public key expiry for ID Token hints (#7293) 2024-01-29 15:11:52 +00:00
key.go fix(oidc): ignore public key expiry for ID Token hints (#7293) 2024-01-29 15:11:52 +00:00
label_policy.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
lockout_policy_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
lockout_policy.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
login_name.go perf: remove owner removed columns from projections for oidc (#6925) 2023-11-20 17:21:08 +02:00
login_policy_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
login_policy.go fix(query): separate login policy queries (#7174) 2024-01-08 21:13:46 +00:00
mail_template.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
member_roles.go fix(query): realtime data on defined requests (#3726) 2022-06-14 07:51:00 +02:00
member.go feat(eventstore): increase parallel write capabilities (#5940) 2023-10-19 12:19:10 +02:00
message_text_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
message_text.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
milestone_test.go feat(storage): read only transactions for queries (#6415) 2023-08-22 10:49:22 +00:00
milestone.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
notification_policy_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
notification_policy.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
notification_provider_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
notification_provider.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
oidc_client_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
oidc_client.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
oidc_settings_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
oidc_settings.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
org_domain_test.go feat(storage): read only transactions for queries (#6415) 2023-08-22 10:49:22 +00:00
org_domain.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
org_member_test.go perf(oidc): optimize client verification (#6999) 2023-12-05 17:01:03 +00:00
org_member.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
org_metadata_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
org_metadata.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
org_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
org.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
password_age_policy_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
password_age_policy.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
password_complexity_policy_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
password_complexity_policy.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
prepare_test.go feat: limit audit trail (#6744) 2023-10-25 11:42:00 +00:00
privacy_policy_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
privacy_policy.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
project_grant_member_test.go perf(oidc): optimize client verification (#6999) 2023-12-05 17:01:03 +00:00
project_grant_member.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
project_grant_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
project_grant.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
project_member_test.go perf(oidc): optimize client verification (#6999) 2023-12-05 17:01:03 +00:00
project_member.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
project_role_test.go perf: remove owner removed columns from projections for oidc (#6925) 2023-11-20 17:21:08 +02:00
project_role.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
project_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
project.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
query_test.go fix(setup): init projections (#7194) 2024-01-25 17:28:20 +01:00
query.go fix(setup): init projections (#7194) 2024-01-25 17:28:20 +01:00
quota_notifications_test.go perf: project quotas and usages (#6441) 2023-09-15 16:58:45 +02:00
quota_notifications.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
quota_periods_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
quota_periods.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
quota_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
quota.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
restrictions_test.go fix: projection version of restrictions (#7028) 2023-12-06 10:30:56 +00:00
restrictions.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
search_query_test.go fix(query): escape wildcards in text search (#7131) (#7135) 2024-01-02 16:27:36 +01:00
search_query.go fix(query): escape wildcards in text search (#7131) (#7135) 2024-01-02 16:27:36 +01:00
secret_generator_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
secret_generators.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
security_policy.go feat: impersonation roles (#7442) 2024-02-28 10:21:11 +00:00
session.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
sessions_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
sms_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
sms.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
smtp_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
smtp.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
system_features_model.go feat(api): feature flags (#7356) 2024-02-28 10:55:54 +02:00
system_features_test.go feat(api): feature flags (#7356) 2024-02-28 10:55:54 +02:00
system_features.go feat(api): feature flags (#7356) 2024-02-28 10:55:54 +02:00
user_auth_method_test.go perf(oidc): optimize client verification (#6999) 2023-12-05 17:01:03 +00:00
user_auth_method.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
user_by_id.sql perf(query): increase speed of user queries (#7126) (#7128) 2024-01-02 14:41:46 +01:00
user_by_login_name.sql perf(query): increase speed of user queries (#7126) (#7128) 2024-01-02 14:41:46 +01:00
user_grant_test.go fix(console): display granted org name in authorizations and show user information (#7116) 2024-01-24 11:36:04 +01:00
user_grant.go fix(console): display granted org name in authorizations and show user information (#7116) 2024-01-24 11:36:04 +01:00
user_membership_test.go perf: remove owner removed columns from projections for oidc (#6925) 2023-11-20 17:21:08 +02:00
user_membership.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
user_metadata_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
user_metadata.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
user_notify_by_id.sql perf(query): increase speed of user queries (#7126) (#7128) 2024-01-02 14:41:46 +01:00
user_notify_by_login_name.sql perf(query): increase speed of user queries (#7126) (#7128) 2024-01-02 14:41:46 +01:00
user_otp.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
user_password.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
user_personal_access_token_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
user_personal_access_token.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
user_test.go feat: user v2 service query (#7095) 2024-01-17 10:00:10 +01:00
user.go feat: user v2 service query (#7095) 2024-01-17 10:00:10 +01:00
userinfo_test.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
userinfo.go refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
zitadel_permission.go perf: remove owner removed columns from projections for oidc (#6925) 2023-11-20 17:21:08 +02:00