1

I've been using the following SPARQL query to find the graphs in a triple-store:

select distinct ?g where { graph ?g {?s ?p ?o} }

This seems inefficient.

Is there a better way?

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
Bill
  • 179
  • 8
  • 1
    That's the standard way. Anything else might be some triple store dependent service, but I don't think there is any other way with SPARQL. – UninformedUser Jan 26 '17 at 21:22
  • 2
    Possible duplicate of [What is the SPARQL query to get the name of all graphs existsing in my fuseki?](http://stackoverflow.com/questions/32274562/what-is-the-sparql-query-to-get-the-name-of-all-graphs-existsing-in-my-fuseki) – Jeen Broekstra Jan 27 '17 at 01:10
  • @JeenBroekstra: Yes. Not necessarily a duplicate, but definitely related. I didn't see that post until you pointed it out. – Bill Jan 27 '17 at 03:25
  • Do you actually have performance issues? – Tomasz Pluskiewicz Jan 27 '17 at 08:16

1 Answers1

2

The form:

SELECT * { GRAPH ?g {} }

will give you all the graph names, no duplicates.

AndyS
  • 16,345
  • 17
  • 21
  • I'm using the free version of GraphDB, version 8.0. This doesn't work. – Bill Jan 28 '17 at 03:48
  • 1
    Suggest you report it GraphDB. It is legal SPARQL 1.1. See 3rd case of eval of "graph" https://www.w3.org/TR/sparql11-query/#defn_evalGraph . – AndyS Jan 29 '17 at 16:07