Search index tuning
This commit is contained in:
@@ -151,11 +151,22 @@ namespace AyaNova.Util
|
||||
|
||||
|
||||
//SEARCH TABLES
|
||||
|
||||
await ExecQueryAsync("CREATE TABLE asearchdictionary (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, word varchar(255) not null)");
|
||||
//Search dictionary words must be unique
|
||||
//Must be unique and also this is hit a *lot* during searches and also indexing
|
||||
await ExecQueryAsync("CREATE UNIQUE INDEX asearchdictionary_word_idx ON asearchdictionary (word);");
|
||||
|
||||
//search key
|
||||
await ExecQueryAsync("CREATE TABLE asearchkey (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, wordid bigint not null REFERENCES asearchdictionary (id), objectid bigint not null, objecttype integer not null)");
|
||||
//todo: I think there is a missing index here, need to look at the search query section again as it was changed several times from the original schema creation
|
||||
//INDEX: Most selective first as there is more unique ID's than unique types
|
||||
//to take advantage of this always query with where objectid=xx and objecttype=yy order
|
||||
|
||||
//Only delete would use this, but, likely not needed as it's not in a loop
|
||||
//await ExecQueryAsync("CREATE INDEX asearchkey_typeid_idx ON asearchkey (objectid, objecttype );");
|
||||
|
||||
//This is what is needed during Searching
|
||||
//search does a lot of hits on searchkey looking for the wordid and optionally objecttype
|
||||
await ExecQueryAsync("CREATE INDEX asearchkey_wordid_otype_idx ON asearchkey (wordid, objecttype);");
|
||||
|
||||
//create translation text tables
|
||||
await ExecQueryAsync("CREATE TABLE atranslation (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null, stock bool, cjkindex bool default false)");
|
||||
|
||||
Reference in New Issue
Block a user