Optimise getInstancesOf to use a single SPARQL query with VALUES