Some query optimization for the future