rewrite sparql for performance