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

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox41 --- fixed

People

(Reporter: bkelly, Assigned: bkelly)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

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)
Attachment #8608776 - Flags: review?(ehsan) → review+
https://hg.mozilla.org/mozilla-central/rev/78db1cd5ffef
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.