SPARQL Examples – Count All Statements

Posted on Aug 31, 2017 (last modified May 7, 2021)

Here’s a SPARQL query that counts all statements (triples) in a repository.

SELECT (COUNT(?s) AS ?triples) WHERE { ?s ?p ?o }

Note that this can be a long running query. For me it took took 21 seconds to count the statements in a repository with 30 million triples.