Repository navigation
Conversation
SQLite default case-insensitive LIKE cannot use a B-tree index for `LIKE 'prefix%'` patterns. On the 29 GB `sdk_messages` table this caused full table scans and hung the Bun dev server. Setting `PRAGMA case_sensitive_like = ON` on every `Database` connection makes prefix LIKE filters use indexes instead. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: daadf79b63
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| constructor(...args: ConstructorParameters<typeof BunDatabaseImpl>) { | ||
| super(...args); | ||
| this.exec('PRAGMA case_sensitive_like = ON'); |
There was a problem hiding this comment.
Preserve LIKE semantics outside indexed scope filters
Enabling this pragma on every database connection changes all ASCII LIKE expressions from SQLite's default case-insensitive behavior to case-sensitive matching, not just the generated session_id LIKE 'space:…%' predicate being optimized. In particular, the read-only connection created by createDbQueryMcpServer now silently omits mixed-case matches from agent-supplied queries such as WHERE title LIKE '%error%', and the daemon's other existing LIKE queries inherit the same compatibility change. Keep the connection-wide default and express the structural prefix filters with an indexable case-sensitive operation such as GLOB or explicit range bounds instead.
Useful? React with 👍 / 👎.
|
Closing: dev sets case_sensitive_like only for db-query scratch databases. Applying it to the main database changes LIKE semantics app-wide, so this needs a decision and a fresh branch, not a rebase. Branch retained. |
$(cat <<"EOF"
Summary
LIKEcannot use a B-tree index forLIKE 'prefix%'patterns.sdk_messagestable this caused full table scans and hung the Bun dev server.PRAGMA case_sensitive_like = ONin theDatabaseconstructor for both the Bun (sqlite-compat.ts) and Node (sqlite-node.ts) implementations, so prefixLIKEfilters use indexes.DatabaseCoretest that verifies a prefixLIKEquery plan usesSEARCHinstead ofSCAN.Test plan
bun run lintpassesbun run typecheckpassesbun run knippassesbun run check:no-commentspasses./scripts/test-daemon.sh 4-space-storagepasses (2256 tests)./scripts/test-daemon.sh 2-handlers-otherpasses (2031 tests)bun run checkhas a pre-existingcheck:test-qualityfailure unrelated to this changeGenerated with Devin
EOF
)