ZeitgeistEngine.__init__(): statement to get last row id is not using the index
Bug #641100 reported by
Markus Korn
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zeitgeist Framework |
Fix Released
|
Undecided
|
Markus Korn |
Bug Description
The attached script is creating a log with ~49k events.
In the constructor of ZeitgeistEngine we need to search for the minimum and maximum event id. In the script I'm doing two different ways of getting these values:
Our current query:
SELECT MIN(id), MAX(id) FROM event
-> this is not using the event index, and takes about 0.096 secunds for me
do the same in two queries:
SELECT MIN(id) FROM event + SELECT MAX(id) FROM event
-> both queries are using the index, and together they take about 0.003 for me
I suggest changing the one query into two to get some speedups.
Related branches
lp:~thekorn/zeitgeist/fix-641100-min-max-use-index
- Zeitgeist Framework Team: Pending requested
-
Diff: 17 lines (+4/-3)1 file modified_zeitgeist/engine/main.py (+4/-3)
Changed in zeitgeist: | |
assignee: | nobody → Markus Korn (thekorn) |
status: | New → In Progress |
Changed in zeitgeist: | |
status: | In Progress → Fix Committed |
Changed in zeitgeist: | |
milestone: | none → 0.5.2 |
Changed in zeitgeist: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
Damn dude, how can sqlite not use the index for the original query..? Just goes to show that it's definitely worth it to scrutinize those query plans!
Totally +1