mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-05 03:25:04 +00:00
fix(waku-store): added an index to improve messages query time
This commit is contained in:
parent
21e9f25276
commit
3f7aa8c6e4
@ -76,7 +76,7 @@ proc createTable*(db: SqliteDatabase): DatabaseResult[void] {.inline.} =
|
||||
## Create index
|
||||
|
||||
template createIndexQuery(table: string): SqlQueryStr =
|
||||
"CREATE INDEX IF NOT EXISTS i_rt ON " & table & " (receiverTimestamp);"
|
||||
"CREATE INDEX IF NOT EXISTS i_msg ON " & table & " (contentTopic, pubsubTopic, senderTimestamp, id);"
|
||||
|
||||
proc createIndex*(db: SqliteDatabase): DatabaseResult[void] {.inline.} =
|
||||
let query = createIndexQuery(DbTable)
|
||||
|
@ -7,7 +7,7 @@ const MESSAGE_STORE_MIGRATION_PATH* = sourceDir / "migrations_scripts/message"
|
||||
const PEER_STORE_MIGRATION_PATH* = sourceDir / "migrations_scripts/peer"
|
||||
const ALL_STORE_MIGRATION_PATH* = sourceDir / "migrations_scripts"
|
||||
|
||||
const USER_VERSION* = 4 # increase this when there is an update in the database schema
|
||||
const USER_VERSION* = 5 # increase this when there is an update in the database schema
|
||||
|
||||
type MigrationScriptsResult*[T] = Result[T, string]
|
||||
type
|
||||
|
@ -0,0 +1,3 @@
|
||||
DROP INDEX IF EXISTS i_rt;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS i_msg ON Message (contentTopic, pubsubTopic, senderTimestamp, id);
|
Loading…
x
Reference in New Issue
Block a user