In SQL, do all the common considerations about indexes apply if everything I'll ever want to query (in the where condition) is when a field is not null?
Is there a special configuration of the index I can apply to cover this specific case?
Eg:
select id
from Accesses
where token is not null;
Is it worth to add the index on token as much as it would be if I had to search for specific token values?
My database is Postgres.
nullis a real value after all. So yes, you do need to index it, assuming that it otherwise needs indexing (sometimes it doesn't... cardinality, etc., the usual rules apply). – Robert Harvey Jul 15 '15 at 14:33