Federated Queries or Virtual Graphs

4 views
Skip to first unread message

charbe...@gmail.com

unread,
Apr 8, 2016, 1:43:24 PM4/8/16
to Stardog
Hello,

I would like to have your opinion regarding the following: I am trying to decide if I should go with federated queries or virtual graphs

I would like to query stardog along with an external DB which exposes a Sparql Endpoint but also a SQL one.

1- The Federated Queries:

SELECT DISTINCT ?a 
WHERE 
{
  ?a a qt:Server.
  ?a qt:hasPoint ?point.
  ?point qt:hasType pdm:WHr_I.


{
      Select ?b ?value
            Where
       {
?b qt:hasValue ?value. 
                 Filter(?value > 12)
      } 
}
filter (?a = ?b)          
}
group by ?a

With the Federated query the two queries are executed in parallel, which means that the two queries will return values and the join will be performed at the Stardog level, at the filter(?a = ?b) operation. To gain performance, I was hoping to execute the local query first and then the return "?a" will be injected to be filtered at the remote query level.

I think that now in Stardog the two queries run in parallel?


2- Virtual Graphs:

SELECT DISTINCT ?a 
WHERE 
{
  ?a a qt:Server.
  ?a qt:hasPoint ?point.
  ?point qt:hasType pdm:WHr_I.


    GRAPH <virtual://db2> 
    {
     ?b qt:hasValue ?value. 

                 Filter(?value > 12)      
    }
 filter (?a = ?b)          
}
group by ?a

Since Stardog handles the SQL generation to the virtual graph, I was wondering if you optimize the SQL query by injecting the returned results form the local query?


Thank you very much for your help.

Cheers, 
Charbel

Michael Grove

unread,
Apr 8, 2016, 1:53:39 PM4/8/16
to stardog
On Fri, Apr 8, 2016 at 1:43 PM, <charbe...@gmail.com> wrote:
Hello,

I would like to have your opinion regarding the following: I am trying to decide if I should go with federated queries or virtual graphs

I would like to query stardog along with an external DB which exposes a Sparql Endpoint but also a SQL one.

1- The Federated Queries:

SELECT DISTINCT ?a 
WHERE 
{
  ?a a qt:Server.
  ?a qt:hasPoint ?point.
  ?point qt:hasType pdm:WHr_I.


{
      Select ?b ?value
            Where
       {
?b qt:hasValue ?value. 
                 Filter(?value > 12)
      } 
}
filter (?a = ?b)          
}
group by ?a

With the Federated query the two queries are executed in parallel, which means that the two queries will return values and the join will be performed at the Stardog level, at the filter(?a = ?b) operation. To gain performance, I was hoping to execute the local query first and then the return "?a" will be injected to be filtered at the remote query level.

I think that now in Stardog the two queries run in parallel?

SPARQL uses bottom-up semantics, so actually, the inner service query is executed first and its results are joined into the rest of the query. Nor are they run in parallel.
 


2- Virtual Graphs:

SELECT DISTINCT ?a 
WHERE 
{
  ?a a qt:Server.
  ?a qt:hasPoint ?point.
  ?point qt:hasType pdm:WHr_I.


    GRAPH <virtual://db2> 
    {
     ?b qt:hasValue ?value. 

                 Filter(?value > 12)      
    }
 filter (?a = ?b)          
}
group by ?a

Since Stardog handles the SQL generation to the virtual graph, I was wondering if you optimize the SQL query by injecting the returned results form the local query?

We use a number of optimizations techniques for the virtual graph queries.

We have a bit more freedom optimizing the virtual graph queries as opposed to the SERVICE based queries, so since your external DB is in fact a relational system, I think the virtual graph approach will work better for you.

Cheers,

Mike
 


Thank you very much for your help.

Cheers, 
Charbel

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

charbe...@gmail.com

unread,
Apr 8, 2016, 2:59:33 PM4/8/16
to Stardog, charbe...@gmail.com
Thank you !

I will go for Virtual graphs then.

I have a community version 4.0.5, 
I am getting the following error when I am trying to add the virtual graph:

./stardog-admin virtual add --format r2rml virtual.properties virtual.ttl

'virtual add' is not supported by the server.

Is it for the Developer and/or Enterprise versions only?

Thanks, 
Charbel

Zachary Whitley

unread,
Apr 8, 2016, 3:19:27 PM4/8/16
to Stardog
I believe that it's only for Developer, Enterprise or 30-day Evaluation.

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.

charbe...@gmail.com

unread,
Apr 8, 2016, 7:10:11 PM4/8/16
to Stardog
Thank you Zachary !
Reply all
Reply to author
Forward
0 new messages