Skip to content

Commit 9641c20

Browse files
committed
fix: add index for session_info on user_id, app_id
1 parent 1afbbd3 commit 9641c20

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
- Adds indexing for `session_info` table on `user_id, app_id` columns
11+
12+
### Migration
13+
14+
```sql
15+
CREATE INDEX IF NOT EXISTS session_info_user_id_app_id_index ON session_info (user_id, app_id);
16+
```
17+
1018
## [7.3.0]
1119

1220
- Adds tables and queries for Bulk Import

src/main/java/io/supertokens/storage/postgresql/queries/GeneralQueries.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ public static void createTablesIfNotExists(Start start, Connection con) throws S
335335

336336
// index
337337
update(con, getQueryToCreateSessionExpiryIndex(start), NO_OP_SETTER);
338+
update(con, getQueryToCreateSessionAppIdUserIdIndex(start), NO_OP_SETTER);
338339
update(con, getQueryToCreateTenantIdIndexForSessionInfoTable(start), NO_OP_SETTER);
339340
}
340341

src/main/java/io/supertokens/storage/postgresql/queries/SessionQueries.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ static String getQueryToCreateSessionExpiryIndex(Start start) {
100100
+ Config.getConfig(start).getSessionInfoTable() + "(expires_at);";
101101
}
102102

103+
static String getQueryToCreateSessionAppIdUserIdIndex(Start start) {
104+
return "CREATE INDEX IF NOT EXISTS session_info_user_id_app_id_index ON "
105+
+ Config.getConfig(start).getSessionInfoTable() + "(user_id, app_id);";
106+
}
107+
103108
public static void createNewSession(Start start, TenantIdentifier tenantIdentifier, String sessionHandle,
104109
String userId, String refreshTokenHash2,
105110
JsonObject userDataInDatabase, long expiry, JsonObject userDataInJWT,

0 commit comments

Comments
 (0)