get words query optimization