Add a created_at, kind index for the global feed

This commit is contained in:
Alex Gleason 2024-05-08 14:34:22 -05:00
parent c6c10e4b7f
commit b16d5b749e
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 15 additions and 1 deletions

View File

@ -4,7 +4,7 @@ export async function up(db: Kysely<any>): Promise<void> {
await db.schema
.createIndex('idx_events_kind_pubkey_created_at')
.on('events')
.columns(['kind', 'pubkey', 'created_at'])
.columns(['kind', 'pubkey', 'created_at desc'])
.execute();
}

View File

@ -0,0 +1,14 @@
import { Kysely } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
await db.schema
.createIndex('idx_events_created_at_kind')
.on('events')
.columns(['created_at desc', 'kind'])
.ifNotExists()
.execute();
}
export async function down(db: Kysely<any>): Promise<void> {
await db.schema.dropIndex('idx_events_created_at_kind').ifExists().execute();
}