On 10/28/15, Marcus Rohrmoser <sqlite at mro.name> wrote:
>
> CREATE TABLE demo (
>   id INTEGER PRIMARY KEY
> );
> EXPLAIN QUERY PLAN SELECT * FROM demo WHERE 0 OR id=3;
> EXPLAIN QUERY PLAN SELECT * FROM demo WHERE id=3;
>
> doesn't use the index in case 1, only in the 2nd case.
>
> Is there a way to hint the query analyzer to use the index? What other
> tricks come into your mind?
>

The query planner in SQLite does not (currently) recognize the special
case of "0 OR ...".  Hence, the only way to get it to use an index is
the second form of the query.
-- 
D. Richard Hipp
drh at sqlite.org

Reply via email to