Skip to content

Commit

Permalink
Add an index for history entry creation time (#674)
Browse files Browse the repository at this point in the history
wlk.yt has about 1 million history entries, and it took about 5 seconds
to get the most recent stuff.

With this index it becomes a few milliseconds.
  • Loading branch information
goto-bus-stop authored Nov 26, 2024
1 parent 5099496 commit 9a88ab0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/migrations/002-sql.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ async function up({ context: uw }) {
.addColumn('source_data', 'jsonb')
.addColumn('created_at', 'timestamp', (col) => col.notNull().defaultTo(now))
.execute();
await db.schema.createIndex('history_entries_created_at')
.on('history_entries')
.column('created_at')
.execute();

await db.schema.createTable('feedback')
.addColumn('history_entry_id', 'uuid', (col) => col.notNull().references('historyEntries.id'))
Expand Down

0 comments on commit 9a88ab0

Please sign in to comment.