Closed Bug 1363569 Opened 7 years ago Closed 7 years ago

improve SQL queries in sdb_FindObjects*

Categories

(NSS :: Libraries, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: keeler, Assigned: keeler)

References

()

Details

sdb_FindObjectsInit creates queries of the form "SELECT ALL * FROM <table name> WHERE <afield=avalue, anotherfield=adifferentvalue>;" but sdb_FindObjects only ever calls sqlite3_column_int(stmt, 0) - i.e. only the id of each row is ever accessed (there's even a comment to this effect). The unfortunate thing about this is that in preparing the statement, sqlite seems to have an O(n * m) algorithm where n is the number of columns in the table and m is the number of selected columns in the query. Since cert9.db has ~115 columns, this introduces a significant overhead. In a test program, the sqlite db was 55 times as slow as the legacy db. Changing the * to "id" makes the sqlite db only 2.5 times as slow as the legacy db in the test.
Target Milestone: --- → 3.31
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.