query optimization

Signed-off-by: Jatin Chauhan <jatin.chauhan@shephertz.co.in>