Aziz Mumtaz
Aziz Mumtaz

Reputation: 95

Sparql- how to get number of triples?

I'm doing a small exercise on sparql. Using Dbpedia Endpoint, I need to count number of triples.

This is my query

      // Get the number of triples //


    SELECT (COUNT(*) as ?Triples) WHERE { ?s ?p ?o}
-------------------------------------------------------
    OUTPUT:

    ( ?Triples = 1625382483 )

Just wondering are the query and the result right? Is this how you get the number of triples?

Upvotes: 7

Views: 8611

Answers (1)

TallTed
TallTed

Reputation: 9444

You can sanity check many things by executing queries directly on a SPARQL endpoint, rather than going through Jena or other intermediary clients. For instance, your query on the DBpedia form, and its results, which shows all triples in that triplestore (currently 1,625,382,483).

If you want the count of triples only within the DBpedia named graph (currently 438,336,517), you'll need to specify that, either in the SPARQL form Default Data Set Name (Graph IRI), or directly in the query, as in --

SELECT (COUNT(*) as ?Triples) 
WHERE 
  { GRAPH <http://dbpedia.org> 
      { ?s ?p ?o } 
  }

-- or --

SELECT (COUNT(*) as ?Triples) 
FROM <http://dbpedia.org> 
WHERE { ?s ?p ?o } 

Upvotes: 13

Related Questions