Siddharth Trikha
Siddharth Trikha

Reputation: 2506

SPARQL query GRAPH unions in-memory?

I was reading a book where I came across this line:

"The SPARQL FROM clause provide another way to define custom union graphs. The FROM clause is used to identify the default graph for a query. The most typical use is to identify a single RDF graph. However if multiple FROM clauses are specified in a query then the contents of those graphs are merged (typically in-memory) to provide a union graph that will form the default graph for the query. This feature of SPARQL can therefore provide another way to assemble a useful graph-agnostic view of a dataset."

Here it says "those graphs are merged (typically in-memory) to provide a union graph".

I am new to Apache Jena, so this got me thinking are such big GRAPH unions happen in-memory ?

So I use TDB to store my graphs and I am querying them using SPARQL and I want to query the "GRAPH union of 2 particular graphs given in multiple FROM clauses" or "GRAPH union of all named graphs":

Will these UNION happens in-memory from my Java code where I use ARQ to query TDB ??

Will this not cause OutOfMemory error lot of times since Graphs can be many ?

This might seem rookie question, pardon my beginner experience in Jena.

Upvotes: 1

Views: 417

Answers (1)

Jeen Broekstra
Jeen Broekstra

Reputation: 22042

I can of course only guess the authors' intent here, but it's possible that they only meant to say that the processing of multiple FROM clauses can happen by retrieving data from each named graph and then as part of the query processing producing the union merge of those as the query result. Note that this doesn't imply that the entire named graphs are kept in memory, merely that as the query executes and iterates over individual results (in memory), it combines results from both source into a "unionized" result.

In any case: it's highly unlikely that any serious SPARQL database (including Jena) processes queries with multiple FROM clauses by loading the entire dataset into memory first.

Upvotes: 1

Related Questions