Oops, posted in haste...
It's actually the UNION strategy that gave a stack overflow above, although
FILTER does also have a similar problem (see below).
BINDINGS seems to work great even with batches of 100,000 resources,
although best results (in that benchmark, on my machine) seem to be for
batches of around 1000. Performance isn't very sensitive to batch size,
although I consistently get poorer performance for intermediate batch sizes
(10000) with better performance either side (1000 or 25000), which is
curious.
However, when selecting the majority of the resources (or all of them, as
for the figures below) it is (unsurprisingly) much faster to query all and
discard a few unwanted results, rather than specifying a subset.
++++
Loading data...OK
Resources = 100000
Triples = 400040
Doing 1 runs, selecting 100000 resources...
[100000] Bindings (batches of 50): 6203
[100000] Bindings (batches of 100): 4688
[100000] Bindings (batches of 1000): 4297
[100000] Bindings (batches of 10000): 5203
[100000] Bindings (batches of 25000): 4469
[100000] Bindings (batches of 50000): 5125
[100000] Bindings (batches of 100000): 5187
[100000] Query all: 1672
[100000] Naive: 31688
[100000] Filter (batches of 50): 6781
[100000] Filter (batches of 100): 7640
[100000] Filter (batches of 1000): 30266
Finished.
++++
Loading data...OK
Resources = 25000
Triples = 100040
Doing 1 runs, selecting 5000 resources...
[5000] Bindings (batches of 50): 703
[5000] Bindings (batches of 100): 250
[5000] Bindings (batches of 5000): 235
[25000] Query all: 453
[5000] Naive: 1890
<UNION omitted>
[5000] Filter (batches of 50): 391
[5000] Filter (batches of 100): 391
Exception in thread "main" java.lang.StackOverflowError
at
com.hp.hpl.jena.sparql.expr.ExprFunction2.visit(ExprFunction2.java:107)
at
com.hp.hpl.jena.sparql.expr.ExprWalker$Walker.visitExprFunction(ExprWalker.java:52)
at
com.hp.hpl.jena.sparql.expr.ExprVisitorFunction.visit(ExprVisitorFunction.java:13)
at
com.hp.hpl.jena.sparql.expr.ExprFunction2.visit(ExprFunction2.java:107)
at
com.hp.hpl.jena.sparql.expr.ExprWalker$Walker.visitExprFunction(ExprWalker.java:52)
at
com.hp.hpl.jena.sparql.expr.ExprVisitorFunction.visit(ExprVisitorFunction.java:13)
at
com.hp.hpl.jena.sparql.expr.ExprFunction2.visit(ExprFunction2.java:107)
at
com.hp.hpl.jena.sparql.expr.ExprWalker$Walker.visitExprFunction(ExprWalker.java:52)
at
com.hp.hpl.jena.sparql.expr.ExprVisitorFunction.visit(ExprVisitorFunction.java:13)
at
com.hp.hpl.jena.sparql.expr.ExprFunction2.visit(ExprFunction2.java:107)
at
com.hp.hpl.jena.sparql.expr.ExprWalker$Walker.visitExprFunction(ExprWalker.java:52)
[...]