Some optimizations for ex using SQL's boolean type