Closed Bug 1166911 Opened 5 years ago Closed 5 years ago
Cache API sqlite code is not hitting storage key index due to IS binary operator
When I implemented storing keys as blobs I had to switch all the "key=value" constraints in the sql to "key IS value". This is because zero-length blobs are represented as NULL in sqlite. The IS operator works, but unfortunately triggers a full table scan instead of using the key index. This can be fixed by using separate query strings. If the key we are searching for is NULL, then explicitly use "IS NULL". Otherwise use the "=value" comparison. For some reason "IS NULL" works with the index, but "IS value" does not.
Hrm, have you asked the sqlite team about this? I wonder if that's a bug or just part of the language...
Its documented behavior on their query optimization page. So I don't think it's a bug.
Dynamically build the query string so we can use IS NULL explicitly if the key is the empty string. Otherwise we use key=:key. https://treeherder.mozilla.org/#/jobs?repo=try&revision=cfa4e72ba663
Assignee: nobody → bkelly
Status: NEW → ASSIGNED
Attachment #8608776 - Flags: review?(ehsan)
You need to log in before you can comment on or make changes to this bug.