Efficient Handling of SPARQL OPTIONAL for OBDA (Extended Version)

Guohui Xiao, Roman Kontchakov, Benjamin Cogrel, Diego Calvanese, and Elena Botoeva

Technical Report, arXiv.org e-Print archive. CoRR Technical Report arXiv:1806.05918 2018. Available at https://arxiv.org/abs/1806.05918.

OPTIONAL is a key feature in SPARQL for dealing with missing information. While this operator is used extensively, it is also known for its complexity, which can make efficient evaluation of queries with OPTIONAL challenging. We tackle this problem in the Ontology-Based Data Access (OBDA) setting, where the data is stored in a SQL relational database and exposed as a virtual RDF graph by means of an R2RML mapping. We start with a succinct translation of a SPARQL fragment into SQL. It fully respects bag semantics and three-valued logic and relies on the extensive use of the LEFT JOIN operator and COALESCE function. We then propose optimisation techniques for reducing the size and improving the structure of generated SQL queries. Our optimisations capture interactions between JOIN, LEFT JOIN, COALESCE and integrity constraints such as attribute nullability, uniqueness and foreign key constraints. Finally, we empirically verify effectiveness of our techniques on the BSBM OBDA benchmark.

   title = "Efficient Handling of SPARQL OPTIONAL for OBDA (Extended
   year = "2018",
   author = "Guohui Xiao and Roman Kontchakov and Benjamin Cogrel and
Diego Calvanese and Elena Botoeva",
   institution = "arXiv.org e-Print archive",
   number = "arXiv:1806.05918",
   note = "Available at https://arxiv.org/abs/1806.05918",