CLEREZZA-981: selecting only the vars used in query