1

I am running a query to select all graphs using filter exists, like this

SELECT * WHERE {
  graph ?g { filter exists { ?s ?p ?o  } }
} 

but its response is

{
  "head": {
    "vars": [
      "g"
    ]
  },
  "results": {
    "bindings": [
      {}
    ]
  }
}

and I am pretty sure that the triplestore store has graphs.

Note: the more classic query works but takes a while, so I was hoping this would improve performance.

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

I double-checked on Jena Fuseki and there the filter exists works.

4
  • the classic query would be select distinct ?g where { graph ?g { } } - this query is also highly optimized on Jena do do just what it has to do as efficiently as possible Commented Jan 12, 2024 at 15:10
  • also what means "I am pretty sure that the triplestore store has graphs" - did you load data into named graphs or not? Or are you taking about vendor specific named graphs to store e.g. triple store specific internal stuff? Commented Jan 12, 2024 at 15:11
  • 1
    To answer both of your questions: I am aware of select distinct ?g where { graph ?g { } } but that never worked on Virtuoso nor on GraphDB. I was trying to find another way. The "pretty sure" means that there are graphs as I mentioned that the ?g { ?s ?p ?o } query works. Commented Jan 15, 2024 at 8:48
  • GraphDB is optimized for this pattern: SELECT DISTINCT ?g WHERE { GRAPH? g { ?s ?p ?o } } Commented May 17 at 8:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.