Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion db/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"@std/assert": "jsr:@std/assert@^1.0.19"
},
"name": "@01edu/db",
"version": "0.2.3",
"version": "0.2.4",
"license": "MIT",
"exports": {
".": "./mod.ts",
Expand Down
8 changes: 8 additions & 0 deletions db/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ export const initEntries = <
[name]: { type },
})

// SQLite only auto-indexes primary keys. fieldId is the PK, so entryId
// needs an explicit index — without it any partial index on entryInternal
// triggers a full table scan of the field table on every join.
sql`
CREATE INDEX IF NOT EXISTS idx_${tableName}_entry_id
ON ${tableName}(entryId)
`.run()

fieldTables[name] = table
fields[name] = table
}
Expand Down