Optimize query variables based on requested data

Same thing is if you have two queries with different filters. Right now reusing func is a bad idea…