On 16/02/15 16:59, Stian Soiland-Reyes wrote:
Can you not select that graph ?gCount ?topic programmatically so each
row is another graph URI and its count?

yes - that is what the UNION form does.

There should be no need for
subqueries, and that could in theory stream back - presumably you
probably don't really care about the order here?

UNION streams.

You can use VALUES for matching the ?topic to your fixed list of 1200 URIs.
http://www.w3.org/TR/sparql11-query/#inline-data

Different query - there is a different variable for each count in Michael's example.

It also needs GROUP BY ...

I've not tested if this would be faster or slower..


Something like:

     SELECT ?topic (count(*) as ?count) WHERE {
      VALUES ?topic { <http://dbpedia.org/resource/Thomas_Mills_Wood>
<http://sws.geonames.org/2633653/> }
      GRAPH ?g { ?s ?p ?topic . }
     }
     GROUP BY ?topic

That is like the UNION example - one row per topic.


(this seems slower at the virtuoso at http://dbpedia.org/sparql but I
have found Virtuoso doesn't do the streaming back as nicely as Fuseki)

Not surprising - it now can't stream at all without some smarts about result ordering and GROUP BY or some fairly weird stats (= expensive to maintain and unlikely to be that useful in many cases) on ?topic / ?g correlations + execution reordering.

Imagine what if the first and last VALUES hit the same ?g.

        Andy



BTW -- do you want out a count of total number of triples across all
graphs that have the ?topic as an object - or a count pr graph that
has ?topic as an object? The query above is the first, but you can
SELECT and GROUP BY ?g as well if you want the second.


Reply via email to