I have a query involving couples of rows which have a less-than-2-hours time-difference (~0.08333 days):
SELECT mt1.*, mt2.* FROM mytable mt1, mytable mt2
You are using an expression index. The documentation says:
The SQLite query planner will consider using an index on an expression when the expression that is indexed appears in the WHERE clause or in the ORDER BY clause of a query, exactly as it is written in the CREATE INDEX statement. The query planner does not do algebra.
So it is not possible to use an index to speed up lookups of a call to abs()
if the indexed expression is only a parameter. (And it is not possible to index the entire abs()
call because it involves two tables.)
So converting the expression as you did is the only way to make it more efficient.
(Please note that a compares
a
and b
first, and then compares the resulting boolean value against c
. This is not what you want.)