Thanks for the report. This is a real bug. SQLite had an optimization that omitted the DISTINCT clause as unnecessary if all terms of the result set were individually not-NULL (which the WHERE clause proved in the example above) and if all terms where elements of a UNIQUE index. But that optimization was incorrect. We also needed to add the constraint that the index should not be a partial index. Fixed by check-in [c2f940b02883e165][1]. [1]: src:/info/c2f940b02883e165>