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

fix: add index for session_info on user_id, app_id #1099

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Fixes

- Fixes issue with user id mapping while refreshing session
- Adds indexing for `session_info` table on `user_id, app_id` columns

### Migrations

Expand All @@ -54,6 +55,8 @@ CREATE INDEX IF NOT EXISTS bulk_import_users_status_updated_at_index ON bulk_imp
CREATE INDEX IF NOT EXISTS bulk_import_users_pagination_index1 ON bulk_import_users (app_id, status, created_at DESC, id DESC);

CREATE INDEX IF NOT EXISTS bulk_import_users_pagination_index2 ON bulk_import_users (app_id, created_at DESC, id DESC);

CREATE INDEX IF NOT EXISTS session_info_user_id_app_id_index ON session_info (user_id, app_id);
```

For MySQL run the following SQL script:
Expand All @@ -77,6 +80,8 @@ CREATE INDEX bulk_import_users_status_updated_at_index ON bulk_import_users (app
CREATE INDEX bulk_import_users_pagination_index1 ON bulk_import_users (app_id, status, created_at DESC, id DESC);

CREATE INDEX bulk_import_users_pagination_index2 ON bulk_import_users (app_id, created_at DESC, id DESC);

CREATE INDEX session_info_user_id_app_id_index ON session_info (user_id, app_id);
```

## [9.3.1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ public static void createTablesIfNotExists(Start start, Main main) throws SQLExc

// index
update(start, getQueryToCreateSessionExpiryIndex(start), NO_OP_SETTER);
update(start, getQueryToCreateSessionAppIdUserIdIndex(start), NO_OP_SETTER);
}

if (!doesTableExists(start, Config.getConfig(start).getTenantConfigsTable())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ static String getQueryToCreateSessionExpiryIndex(Start start) {
+ Config.getConfig(start).getSessionInfoTable() + "(expires_at);";
}

static String getQueryToCreateSessionAppIdUserIdIndex(Start start) {
return "CREATE INDEX session_info_user_id_app_id_index ON "
+ Config.getConfig(start).getSessionInfoTable() + "(user_id, app_id);";
}

public static void createNewSession(Start start, TenantIdentifier tenantIdentifier, String sessionHandle,
String userId, String refreshTokenHash2,
JsonObject userDataInDatabase, long expiry, JsonObject userDataInJWT,
Expand Down
Loading