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.
Created attachment 8608776 [details] [diff] [review] Modify Cache API sqlite code to use IS NULL literal when comparing an empty key. r=ehsan 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)
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
status-firefox41: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
You need to log in before you can comment on or make changes to this bug.