robstewart57/hsparql

Count number of triples

Opened this issue · 0 comments

The following SPARQL query allows to fetch the number of triples in the database:

SELECT (COUNT(*) as ?count) WHERE {
  ?s ?p ?o .
}

However, there's doesn't seem to an equivalent of writing that query in HSparql.

The closest SPARQL query would be:

SELECT (COUNT(?s) as ?count) WHERE {
  ?s ?p ?o .
}

Which translates to:

countTriplesQuery :: Query SelectQuery
countTriplesQuery = do
  s <- var
  p <- var
  o <- var
  t <- triple s p o
  
  c <- var
  select [count s `as` c]

However, this SPARQL query is much slower than the 1st when tested on Wikidata.

Possible enhancement ?