I realize that the exact question has been asked before on stack overflow with only a vaguely conclusive answer: link
So here it is again.
Table A: Has an integer column which is nullable, along with an index. Query:
SELECT *
FROM table
WHERE column IS NULL
LIMIT 10;
Will an index be used, or will mysql do a full table scan until it has found 10 entries?
i think this should be helpful:
http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html
A search using col_name IS NULL employs indexes if col_name is indexed.
The only way to know that for sure in your specific case is to run "EXPLAIN SELECT" on your query.
It really depends on the number of NULLs in your table compared with total number of rows; whether table statistics have been updated, etc...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With