Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

cartesian product query plan when using hexastore backend #59

Closed
kasei opened this Issue Apr 11, 2012 · 5 comments

Comments

Projects
None yet
2 participants
Owner

kasei commented Apr 11, 2012

KjetilK reports via irc an erroneous cartesian product in the query plan when using hexastore as a backend:

12:01 <@kjetilkwork:#perlrdf> { ?s gd:senter ?senter ;
12:01 <@kjetilkwork:#perlrdf> gn:officialName ?navn .
12:01 <@kjetilkwork:#perlrdf> ?senter gn:officialName ?senternavn .
12:01 <@kjetilkwork:#perlrdf> }
12:53 <@kjetilkwork:#perlrdf> seems Hexastore gets confused
12:53 <@kasei:#perlrdf> yeah, it's possible for that to do a cartesian product if the query planner gets confused.
12:54 <@kjetilkwork:#perlrdf> no shared variable -- cartesian product at /usr/local/share/perl/5.10.1/RDF/Trine/Store/Hexastore.pm line 455.

This shouldn't happen on this query, as there are join variables between the triple patterns. Figure out why the planner is doing the wrong thing.

Contributor

kjetilk commented Apr 11, 2012

This is my config:

{
    "base_uri"  : "http://data.lenka.no/",
    "store" : {
               "storetype"  : "Hexastore",
               "sources" : [ {
                            "file" : "/var/www/data.lenka.no/htdocs/dumps/kommune-navn.ttl",
                            "syntax" : "turtle"
                           },
                           {
                            "file" : "/var/www/data.lenka.no/htdocs/dumps/fylke-geonames.ttl",
                            "syntax" : "turtle"
                           },
                           {
                            "file" : "/var/www/data.lenka.no/htdocs/dumps/kommunesentre-geonames.ttl",
                            "syntax" : "turtle"
                           } ]

              },
    "namespaces" : {
                     "gn" : "http://www.geonames.org/ontology#",
                     "owl" : "http://www.w3.org/2002/07/owl#",
                     "pos" : "http://www.w3.org/2003/01/geo/wgs84_pos#",
                     "gd" : "http://vocab.lenka.no/geo-deling#",
                     "cc" : "http://creativecommons.org/ns#"
                   },
    "endpoint" : {
                   "html": {
                            "resource_links": true
                           }

                 }
}
Contributor

kjetilk commented Apr 11, 2012

Got error:
no shared variable -- cartesian product at /usr/local/share/perl/5.10.1/RDF/Trine/Store/Hexastore.pm line 455.

Owner

kasei commented Apr 11, 2012

The first problem happening here is that RDF::Trine::Store->get_pattern is taking the list of three triple patterns in the BGP, and using the first triple as the right-hand side of the join. So you end up doing join(join(t2, t3), t1) instead of the more natural join(join(t1, t2), t3). Commit 67f537c fixes this.

Longer-term, RDF::Trine::Store->get_pattern needs to make sure that the join order is taking into account join variables and not introducing cartesian joins.

Owner

kasei commented May 18, 2012

I believe the addition and use of RDF::Trine::Pattern->sort_for_join_variables (commit 468d1d0) fixes the join ordering issue.

@kasei kasei closed this May 18, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment