Hwllo,

On 2018-01-05 21:19, x wrote:
Tbl has 2.4 million records and has an INTEGER PRIMARY KEY ID which is NOT NULL.

SELECT ID FROM Tbl where ID = NULL

It has no sense as ``='' returns NULL when one of operands is NULL. NULL evaluates to FALSE. Above query can be described as SELECT NOTHING.

SELECT ID FROM Tbl WHERE ID IS NULL

takes around 350 milliseconds to run and the explain query plan shows it uses 
some covering index.

SQLite is looking for NULL values of ID.

Please, please, do not require to optimize such query due to the fact that your field does not contain NULLs. :-)

I’m sure I’ve read something before about this but can’t find it in the 
documentation?

STH IS STH allows NULLs and returns 1 if both are NULLs, 0 otherwise. http://sqlite.org/lang_expr.html#isisnot

-- best regards

Cezary H. Noweta
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to