SQLite Forum

SQLite doesn't use indexes for bitwise clauses?
Login
In one case I'm fetching data from table A that meets criteria in table B

```
SELECT * FROM A
INNER JOIN B ON B.a=A.rowid
WHERE B.name=? AND B.bitfield & 0x0040 != 0;
```

Assume table B has more columns than `bitfield`. Why do I need a table scan of B if I can `CREATE INDEX x ON B(name, bitfield);`? Table B has other columns so the index has greater density e.g. if there's 2 records per page for table B but 20 per index page. Table scans are significantly less efficient than indexes.

I'm not using bitwise operators for relational comparisons. I'm using an INTEGER column as a bitfield and only interested in (not)equality. ORDER BY doesn't help.