Inner queries have problems with query index