Optimize searching for users on Postgres (#9782)
The searches on Postgres using LIKE with prefix matching will only use an index if it has the text_pattern_ops flag (forcing C collation). This drops the old indexes and adds properly optimized ones.
Этот коммит содержится в:
коммит произвёл
Jesse Hallam
родитель
0c5f60f89b
Коммит
7a758eae72
@@ -521,6 +521,14 @@ func UpgradeDatabaseToVersion56(sqlStore SqlStore) {
|
|||||||
|
|
||||||
// migrating user's accepted terms of service data into the new table
|
// migrating user's accepted terms of service data into the new table
|
||||||
sqlStore.GetMaster().Exec("INSERT INTO UserTermsOfService SELECT Id, AcceptedTermsOfServiceId as TermsOfServiceId, :CreateAt FROM Users WHERE AcceptedTermsOfServiceId != \"\" AND AcceptedTermsOfServiceId IS NOT NULL", map[string]interface{}{"CreateAt": model.GetMillis()})
|
sqlStore.GetMaster().Exec("INSERT INTO UserTermsOfService SELECT Id, AcceptedTermsOfServiceId as TermsOfServiceId, :CreateAt FROM Users WHERE AcceptedTermsOfServiceId != \"\" AND AcceptedTermsOfServiceId IS NOT NULL", map[string]interface{}{"CreateAt": model.GetMillis()})
|
||||||
|
|
||||||
|
if sqlStore.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||||
|
sqlStore.RemoveIndexIfExists("idx_users_email_lower", "lower(Email)")
|
||||||
|
sqlStore.RemoveIndexIfExists("idx_users_username_lower", "lower(Username)")
|
||||||
|
sqlStore.RemoveIndexIfExists("idx_users_nickname_lower", "lower(Nickname)")
|
||||||
|
sqlStore.RemoveIndexIfExists("idx_users_firstname_lower", "lower(FirstName)")
|
||||||
|
sqlStore.RemoveIndexIfExists("idx_users_lastname_lower", "lower(LastName)")
|
||||||
|
}
|
||||||
//saveSchemaVersion(sqlStore, VERSION_5_6_0)
|
//saveSchemaVersion(sqlStore, VERSION_5_6_0)
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,11 +94,11 @@ func (us SqlUserStore) CreateIndexesIfNotExists() {
|
|||||||
us.CreateIndexIfNotExists("idx_users_delete_at", "Users", "DeleteAt")
|
us.CreateIndexIfNotExists("idx_users_delete_at", "Users", "DeleteAt")
|
||||||
|
|
||||||
if us.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
if us.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||||
us.CreateIndexIfNotExists("idx_users_email_lower", "Users", "lower(Email)")
|
us.CreateIndexIfNotExists("idx_users_email_lower_textpattern", "Users", "lower(Email) text_pattern_ops")
|
||||||
us.CreateIndexIfNotExists("idx_users_username_lower", "Users", "lower(Username)")
|
us.CreateIndexIfNotExists("idx_users_username_lower_textpattern", "Users", "lower(Username) text_pattern_ops")
|
||||||
us.CreateIndexIfNotExists("idx_users_nickname_lower", "Users", "lower(Nickname)")
|
us.CreateIndexIfNotExists("idx_users_nickname_lower_textpattern", "Users", "lower(Nickname) text_pattern_ops")
|
||||||
us.CreateIndexIfNotExists("idx_users_firstname_lower", "Users", "lower(FirstName)")
|
us.CreateIndexIfNotExists("idx_users_firstname_lower_textpattern", "Users", "lower(FirstName) text_pattern_ops")
|
||||||
us.CreateIndexIfNotExists("idx_users_lastname_lower", "Users", "lower(LastName)")
|
us.CreateIndexIfNotExists("idx_users_lastname_lower_textpattern", "Users", "lower(LastName) text_pattern_ops")
|
||||||
}
|
}
|
||||||
|
|
||||||
us.CreateFullTextIndexIfNotExists("idx_users_all_txt", "Users", strings.Join(USER_SEARCH_TYPE_ALL, ", "))
|
us.CreateFullTextIndexIfNotExists("idx_users_all_txt", "Users", strings.Join(USER_SEARCH_TYPE_ALL, ", "))
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user