[Views] optimize Database query