test tree view queries and optimize them as well