Query compilation should happen within a db transaction