Query optimization

shape