-
Notifications
You must be signed in to change notification settings - Fork 12
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: index updates #152
fix: index updates #152
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -102,30 +102,44 @@ public static String getQueryToCreateTenantIdIndexForUsersTable(Start start) { | |||||
+ Config.getConfig(start).getUsersTable() + "(app_id, tenant_id);"; | ||||||
} | ||||||
|
||||||
static String getQueryToCreateUserPaginationIndex(Start start) { | ||||||
return "CREATE INDEX all_auth_recipe_users_pagination_index ON " + Config.getConfig(start).getUsersTable() | ||||||
+ "(primary_or_recipe_user_time_joined DESC, primary_or_recipe_user_id DESC, tenant_id DESC, app_id DESC);"; | ||||||
static String getQueryToCreateUserPaginationIndex1(Start start) { | ||||||
return "CREATE INDEX all_auth_recipe_users_pagination_index1 ON " + Config.getConfig(start).getUsersTable() | ||||||
+ "(app_id, tenant_id, primary_or_recipe_user_time_joined DESC, primary_or_recipe_user_id DESC);"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change the changelog There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
} | ||||||
|
||||||
static String getQueryToCreatePrimaryUserIdIndex(Start start) { | ||||||
static String getQueryToCreateUserPaginationIndex2(Start start) { | ||||||
return "CREATE INDEX all_auth_recipe_users_pagination_index2 ON " + Config.getConfig(start).getUsersTable() | ||||||
+ "(app_id, tenant_id, primary_or_recipe_user_time_joined ASC, primary_or_recipe_user_id DESC);"; | ||||||
} | ||||||
|
||||||
static String getQueryToCreateUserPaginationIndex3(Start start) { | ||||||
return "CREATE INDEX all_auth_recipe_users_pagination_index3 ON " + Config.getConfig(start).getUsersTable() | ||||||
+ "(recipe_id, app_id, tenant_id, primary_or_recipe_user_time_joined DESC, primary_or_recipe_user_id DESC);"; | ||||||
} | ||||||
|
||||||
static String getQueryToCreateUserPaginationIndex4(Start start) { | ||||||
return "CREATE INDEX all_auth_recipe_users_pagination_index4 ON " + Config.getConfig(start).getUsersTable() | ||||||
+ "(recipe_id, app_id, tenant_id, primary_or_recipe_user_time_joined ASC, primary_or_recipe_user_id DESC);"; | ||||||
} | ||||||
|
||||||
static String getQueryToCreatePrimaryUserIdAndTenantIndex(Start start) { | ||||||
/* | ||||||
* Used in: | ||||||
* - does user exist | ||||||
* | ||||||
* */ | ||||||
return "CREATE INDEX all_auth_recipe_users_primary_user_id_index ON " + Config.getConfig(start).getUsersTable() | ||||||
+ "(app_id, primary_or_recipe_user_id);"; | ||||||
return "CREATE INDEX all_auth_recipe_users_primary_user_id_and_tenant_id_index ON " + | ||||||
Config.getConfig(start).getUsersTable() | ||||||
+ "(primary_or_recipe_user_id, app_id);"; | ||||||
} | ||||||
|
||||||
static String getQueryToCreatePrimaryUserIdAndTenantIndex(Start start) { | ||||||
static String getQueryToCreateRecipeIdIndex(Start start) { | ||||||
/* | ||||||
* Used in: | ||||||
* - user count query | ||||||
* | ||||||
* */ | ||||||
return "CREATE INDEX all_auth_recipe_users_primary_user_id_and_tenant_id_index ON " + | ||||||
return "CREATE INDEX all_auth_recipe_users_recipe_id_index ON " + | ||||||
Config.getConfig(start).getUsersTable() | ||||||
+ "(app_id, tenant_id, primary_or_recipe_user_id);"; | ||||||
+ "(recipe_id, app_id, tenant_id);"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
} | ||||||
|
||||||
private static String getQueryToCreateAppsTable(Start start) { | ||||||
|
@@ -249,9 +263,12 @@ public static void createTablesIfNotExists(Start start) throws SQLException, Sto | |||||
update(start, getQueryToCreateUsersTable(start), NO_OP_SETTER); | ||||||
|
||||||
// index | ||||||
update(start, getQueryToCreatePrimaryUserIdIndex(start), NO_OP_SETTER); | ||||||
update(start, getQueryToCreateUserPaginationIndex(start), NO_OP_SETTER); | ||||||
update(start, getQueryToCreateUserPaginationIndex1(start), NO_OP_SETTER); | ||||||
update(start, getQueryToCreateUserPaginationIndex2(start), NO_OP_SETTER); | ||||||
update(start, getQueryToCreateUserPaginationIndex3(start), NO_OP_SETTER); | ||||||
update(start, getQueryToCreateUserPaginationIndex4(start), NO_OP_SETTER); | ||||||
update(start, getQueryToCreatePrimaryUserIdAndTenantIndex(start), NO_OP_SETTER); | ||||||
update(start, getQueryToCreateRecipeIdIndex(start), NO_OP_SETTER); | ||||||
} | ||||||
|
||||||
if (!doesTableExists(start, Config.getConfig(start).getUserLastActiveTable())) { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add psql prs to this checklist: supertokens/supertokens-core#742 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done