A bit of query optimization