On 13 Oct 2011, at 09:16, David Allsopp wrote:
> Hi all,
>
> I frequently need to query specific subsets of resources; the subsets are
> determined at runtime, so are unpredictable - I may need to query all the
> resources, or just a handful. Each query extracts a few properties.
<snip>
> What I am currently trying is a query that lists the resources of interest,
> using a filter and the IN function, e.g.
>
> SELECT ?res ?lat ?lon {?res <http://example.com#lat> ?lat; <
> http://example.com#lon> ?lon . filter( ?res IN(<
> http://example.com#myresource123>,<http://example.com#myresource124>,...) )}
> Is the performance of the IN() function O(n), and if so can anything be
> easily done to improve this?
I suspect the answers are: yes, and maybe.
> and, is there a better way to do this kind of query?
I've never used them, but how about using bindings? [1]
SELECT ?res ?lat ?lon
{
?res <http://example.com#lat> ?lat;
<http://example.com#lon> ?lon .
}
BINDINGS ?res {
(<http://example.com#myresource123>)
(<http://example.com#myresource124>)
}
My naïve understanding is that this ought to operate like a regular join.
Damian
[1] <http://www.w3.org/TR/sparql11-federated-query/#bindings>