# A Two-Phase Method for Optimization of the SPARQL Query

Authors: Xiaoqing Lin; Dongyang Jiang
Journal: Journal of Sensors
 (2022)

---

## Abstract

With a rapid growth in the available resource description framework (RDF) data from disparate domains, the SPARQL query processing with graph structures has become increasingly important. In this pursuit, we designed a two-phase SPARQL query optimization method to process the SPARQL query. The structural characteristics of RDF data graphs, predicate path sequence indices (PPS-indices), were used to efficiently prune the search space, which captured the inherent features of the RDF data graphs, while the database is updated. Our storage model was based on a relational database. Compared to a baseline solution, the proposed method effectively reduced the cardinalities of the intermediate results during the query processing, and at least an order of magnitude improvement is achieved in filtering performance, thereby improving the efficiency of the query execution.


---

## Body

## 1. Introduction

After the advent of RDF as a standard model of data representation and exchange in the Semantic Web, the availability of the RDF data has immensely increased. RDF data is a collection of statements, in the form of a triple of subject, predicate, and object, where predicate connects the subject and the object. SPARQL is a standard RDF data query language. SPARQL is widely used due to the useful web information that can be obtained from RDF data. However, large amounts of redundant intermediate results appear during executing SPARQL queries, especially in the processing of the large-scale RDF data, which greatly reduces efficiency of SPARQL query. Therefore, optimization of the SPARQL query has attracted a significant attention. With the rapid development of Semantic Web technology, ontologies have been widely applied in semantic data mining. Semantic data mining is the searching process of information hidden in a large amount of data by incorporating the domain knowledge. Ontology is actually a formal representation of a set of concepts in a specific field and the relationships between them. The present studies exploited the domain knowledge to filter out the useless intermediate results. In our two-phase optimization method, in the first stage, an input SPARQL query is divided into different blocks, and the triple pattern containing the same variable is classified into one block where each block has only one variable. The triple patterns in each block are sorted by selectivity to obtain the optimal query execution plan, and then, the triple with the largest selectivity is chosen to execute the query. In the second stage, for the remaining triple pattern containing two variables, the redundant vertices are filtered according to prebuilt PPS-indices, and finally query results are generated. Along with the structural characteristics of RDF data graph, PPS-indices are employed, and the storage based on relational databases is combined together to optimize the SPARQL query.


## 2. Overview and Related Work

Our storage model consists of a relational database suitable for handling large-scale RDF data. Earlier RDF search engines used relational database management systems to store RDF triples, such as Jena [1] and Sesame [2] which store RDF triples in the form of triple tables, and used the query processing module of the relational database management system to process RDF data. However, these systems exhibit poor scalability for large-scale data. SW-store [3], RDF-3x [4], x-RDF-3X [5], Hexastore [6], and gStore [7] can effectively handle large-scale Semantic Web data; SW-store uses vertical partition storage, wherein splitting the triple table by the predicate can quickly merge and join. At present, most SPARQL optimization techniques mainly reduce the intermediate results produced in the join process by formulating an optimal query execution plan. The connection order of the query affects the amount of the intermediate results. In earlier studies [4, 5], dynamic programming was used to estimate the optimal query execution plan. This type of method has an exponential amount of time and space overhead and does not use the RDF data graph structure. In another study [6], six permutation and combination indices of triples (subject, predicate, and object) were built, which could perform effective connection operations, but the index storage overhead was relatively large. The system used MapReduce and HBase, and an abstract RDF data was exploited to decrease the amount of intermediate data [8].Graphs have become increasingly important in SPARQL query processing. In this pursuit, the VS tree and VS∗ tree indices were developed, which used the subgraph matching to process the wildcard or precise SPARQL query processing [7]. A directed supersemantic query graph was used to extract the structural query intention of the question, based on which Q/A on RDF was reduced to the graph matching problem [9]. Nowadays, Semantic Web ontologies have become an indispensable technology for intelligent processing knowledge and provide a framework for conceptual models of shared domains. Domain knowledge can be used as a set of prior knowledge for constraints to help guide the search path and reduce search space, during the search and pattern generating process [10–16]. A set of preconstructed semantics-aware indexes were constructed [17]. In order to capture the ontology information, as well as the data information, an RDF hypergraph representation was developed [18], which is a little similar to [19]. Further, the ontologies were used to prune space and filter the association rule mining results [16, 20, 21]. Ontologies were later exploited to help the subjective analysis for the association rule postpruning task [22]. In the study [23], the redundant intermediate results were filtered out through the RDF graph predicate path sequence indices, but we do not deal with the triple pattern containing text and empty vertices. Index information method implements a query optimization, dynamically calculating the query cost for large-scale RDF data, then formulating the optimal query plan by the connection order cost. However, large amounts of storage space overhead are required [24, 25]. An inductive learning algorithm was later developed that could automatically select the useful join paths and properties to construct rules from an ontology with many concepts [26], thereby leading to an effective optimization of the SPARQL query.Motivated by these observations, we exploited the feature of RDF graph and advantages of relational database to refine the RDF triples, so as to improve the efficiency where on the one hand we implemented the join operation based on relation model storage, and on the other hand, we constructed RDF graph indices (PPS-indices) using graph exploration. The traditional indexing approach may encounter challenges such as graphs. This is because a complex RDF graph may contain an exponential number of paths. Though six permutation indices of triples could speed up the query processing, the storage overhead was increased [6]. In order to help processing graph queries, our method constructed the PPS-indices that only kept all discriminative segments which were refined from the set of frequent structures, thus scaling down the number of frequent paths to be indexed. By the PPS-indices, a lot of useless intermediate results could be greatly reduced. We calculated all indices in advance, and our method was very effective for the query processing of long path patterns in RDF data. TripleBit dynamically computed optimal execution orderings for join queries. However, it was not very effective in processing these long path patterns [27]. In the study [4], only given triple patterns could be processed. Any graph structure information in RDF data was not considered in [4, 5, 27]. Our method used the RDF graph structure characteristics, and our experimental results have shown that our proposed method was more effective for RDF data than theirs.


### 2.1. SPARQL and Query Execution Plan

SPARQL has been recommended by the W3C as the standard query language for RDF data. It is a query for obtaining the results through matching triples on the RDF data [28]. A basic SPARQL query mainly consists of two parts, the SELECT clause and the WHERE clause. Among them, “pattern1”, “pattern2”, etc. are all triple patterns, and the operator “.” connects the two triple patterns. Each triple pattern is composed of a subject, predicate, and object, and these three items are either text or variables. The query uses the text to represent the known and employs variables to denote the unknown, as shown in the query example:SELECT ?variable1 ?variable2 … WHERE { pattern1. pattern2…}The following is the ninth query example Q9 from the LUBM benchmark. This example queries all students, teachers, and courses and satisfies that the courses of students are taught by the teacher and the teacher is the students’ instructor. Among them, the first two lines “rdf” and “ub” are all prefixes, and “?Xrdf:typeub:Student” is a triple pattern. The SPARQL queries processed in this study include triple patterns with the predicate as a variable (see Section 2.4).PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>PREFIX ub:<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#>SELECT ?X ?Y ?ZWHERE{?X rdf:type ub:Student.?Y rdf:type ub:Faculty.?Z rdf:type ub:Course.?X ub:advisor ?Y.?Y ub:teacherOf ?Z.?X ub:takesCourse ?Z }A query execution plan for the above example is shown in Figure1, which is an operation tree. A SPARQL query includes multiple joins, so an improper query join order can produce large amounts of redundant intermediate results. As shown in Table 1, the third and fourth rows present the amount of intermediate results during the join process. The fourth row “T4⋈T5⋈T6” join produces 600,000 intermediate results, but only 2000 of the final results, at least 598,000 redundant intermediate results, are generated in this process. As a result, the size of the result set of each connection affects the next join operation. Therefore, in order to reduce the intermediate results as much as possible, in the first stage, it is important to adjust the join sequence and put the join producing fewer intermediate results in the front. In the second stage, the redundant vertices of the remaining triple patterns are filtered out using predicate path sequence indices (see Section 2.4 for details).Figure 1
A query plan for Q9.Table 1
The cardinality of intermediate results.
Different joinsThe cardinality of intermediate resultsT1⋈T2⋈T3⋈T4⋈T5⋈T62000T1⋈T2⋈T31,000,000T4⋈T5⋈T6600,000


### 2.2. SPARQL Query Optimization

We employed the SPARQL queries as graphs instead of trees. The system process flow is shown in Figure2. In the first stage, the SPARQL query graph is divided into blocks, reordered according to the cost of each join within the block, and partial joins are executed. The cost is estimated based on the amount of intermediate results produced by the joins in the second stage, wherein we used the PPS-indices that were built beforehand to refine the triples. This process is somewhat similar to the filtering of the predicate path [23]. While filtering, the longest PPS-indices were employed for matching the filtering instead of all predicate paths within a path length range. This avoided excessively double calculation, so as to improve the query efficiency (see Section 2.4).Figure 2
The system process flow.The query execution plan is a graph instead of a tree, which is convenient for reusing the results of the intrablock joins. Figure3(a) shows the Q9 query graph. In the first stage, the SPARQL query graph is divided into different blocks containing the same join variables. Figure 3(b) is a part of the Q9 query graph. According to the triple pattern containing the same join variable, “?X” are classified into one block. Of course, a triple pattern with two variables, such as “?Xub:advisor?Y”, can be classified into one block by the variable “?X”, or it can be classified into one block by the variable “?Y”. Each block belongs to a star join. A star denotes a join between two subjects. For instance, in the above example, “T1⋈T2” and “T1⋈T3” all belong to the star join, which is the ternary description of the predicate in the star join. The group mode (including a variable) is reordered according to selectivity, and partial joins are performed to filter out the useless intermediate results.Figure 3
A query graph for Q9 and one of its blocks: a query graph for Q9 (a) and a block for Q9 query graph (b).
(a)(b)


### 2.3. Estimation of Selectivity

The selectivity is based on the number of triples of the matching join,Tn, as shown in formula (1), where the degree of selectivity is inversely proportional to the number of matched triples. That is, the number of corresponding matched triples is larger, and the degree of selection is smaller. For example, if #T1<#T2<#T3, then selT1>selT2>selT3. In order to save the space and time, the calculation of SELECTIVITY (selection degree) generally contains at most one query variable triple pattern, and the most frequent triple pattern is ?s,p,o. Given the object o and the predicate p of a triple, the value of the subject s in the corresponding triple can be obtained.
(1)SELECTIVITY=minimumselT1,selT2,⋯,selTn.We built an OPS (object, predicate, and subject) index, as presented in [6]. By specifying the object and predicate, the corresponding subject Id list and cardinals of matching triples were obtained, so as to complete the optimal execution within the block. The plan and structure are shown in Table 2. The joins with a small number of connections were performed, so as to minimize the unnecessary joins.Table 2
OPS index.
ObjectPredicateSubjectId“FullProfessor0”Name1(FullProfessor0)“University0”Name2(University0)“Department0”Name3(Department0)


### 2.4. Predicate Path Sequence Indices (PPS-Indices)

In the second stage, we construct the predicate path sequence indices to filter the remaining joins in the second stage. PPS-indices were extracted from large-scale RDF data graphs by the depth first search (DFS). The definition of the RDF data graph was adopted according to the study [29], as shown by Definition 1. We defined an RDF entity-relationship graph for building the PPS-indices, as defined in Section 2.Definition 1 (RDF graph).
An RDF data graph is a tuple (V,L,E), where V is a finite set of vertices, VE represents entity vertices, VC represents class vertices, and VV represents the data vertices, forming a disjoint union VE⊎VC⊎VV. L is a limited set of edge labels, L=LR⊎LAtype,subclass, where LR represents the edge between entities and LA represents the edge between entities and data values. E is a finite edge set; the form of the edge is ev1,v2, where v1,v2∈VE,e∈L, only v1,v2∈VE,e∈LR; e∈LA if and only if v1∈VE and v2∈VV; e=type only when v1∈VE and v2∈Vc; and e=subclass only when v1,v2∈VC.Definition 2 (RDF entity-relationship graph,G′).
An RDF entity relationship graphG′ is a triple (V′,L′,E′), where vertex V′=VE, edge label L′=LR, and E′⊂E,E′ connects the two entity vertices. VE represents a collection of entity vertices (e.g., IRIs). Only when the edge ev1,v2∈E′and v1,v2∈VE exist in the RDF data does the edge ev1,v2∈VE exist in the RDF entity relationship graph.PPS-indices are based on the RDF entity relationship graph, excluding the data value and type triples, as shown in Figure4. The triples containing values are processed in the first stage.Definition 3 (inbound predicate path sequence).
The inbound predicate path is a sequence of triple predicates. If the terminal vertex of a path ise, it is said to be an inbound predicate path of e.Figure 4
RDF entity relationship graph.For example, for the join of “?Xub:advisor?Y.?Yub:teacherOf?Z” in Q9, there is an inbound predicate path sequence of the variable “?Z”, “ub:advisor⟶ub:teacherOf”. Table 3 shows the list of vertices pointed to by the predicate path index in Figure 4. Through such a list of vertices, useless intermediate vertices can be filtered out firstly, thereby avoiding more unnecessary join operations. For example, if there is a link in a SPARQL query, “?n1p1?n2.?n2.p2?n3.?n3?p3?n4”, the predicate path “<p1,p2,p3>” can be found that contains the vertex Id list “8, 9” for filtering the result set, without having to merge a large number of intermediate result sets.Table 3
Vertex lists for predicate path indices.
Path lengthPredicate path sequenceVertex Id lists1<p1>2, 5, 6, 12<p2>2, 3, 7, 9<p3>4, 7, 8, 9, 10, 112<p1,p2>2, 3, 7<p2,p1>5<p2,p2>3<p2,p3>4, 8, 9<p3,p1>5<p3,p2>93<p1,p2,p3>8, 9<p2,p1,p1>6<p2,p1,p2>7<p2,p3,p3>11<p3,p1,p2>2, 7<p3,p1,p3>10We obtained ann edge predicate sequence using the DFS algorithm. All bold edges in Figure 5 form a searching tree. The searching order of each vertex is marked below it. It can be seen from Figure 6 that the order of being searched for forward edges is 1,2, 2,3, and 2,4. We specify that for any vertex v′, all of its backward edges should be behind the forward edge that points to v′. For vertex 3, its backward edge 3,1 should appear after 2,3. Among the backward edges from the same vertex, an order is enforced: given vertex Id i and its two backward edges, i,j,i,k; if j<k, then edge i,j will appear before edge i,v. Thus, we obtain the ordering of edges in the RDF data graph. Based on the above order, a complete edge sequence is formed (Figure 5) as <1,2,2,3,3,1,2,4>. We call this sequence the DFS code. Since there are a lot of different searching trees in a graph, each of which can form a DFS sequence code; a lexicographic order was designed to order the DFS code [30, 31]. We denote a labeled edge by its predicate without vertices. Thus, the edge predicate path sequence of Figure 5 can be written as <p1,p1,p2,p2>.Figure 5
DFS code generation.Figure 6
PPS-index tree.A PPS-index tree storing PPS-indices is shown in Figure6, where each vertex stands for a sequential segment (a minimal sequence code). Here, two discriminative segments f1=<p1> and f9=<p1,p2,p1> are kept in the PPS-index tree. Pi is used to denote predicate of edges in DFS codes. Though segments f2,f3 on level 1 are not the discriminative segments, f2 and f3 have to be kept for connecting the vertices f5, f6, and f7.The PPS-index tree is a prefix that keeps all discriminative segments with sizen in level n (segments with size 0 denote subgraphs that have one vertex and no edges). This discriminative predicate path is adapted from the concept in an earlier study [32]. In this prefix tree, if t is a prefix of t′, t is an ancestor of t′. All black vertices represent the discriminative segments, and white vertices represent the intermediate vertices of the whole PPS-index tree. In each black node, fi denotes a list of predicate path sequence; for instance, f1 is <p1> and f5 is <p2,p1>. PPS-indices store the discriminative segments as well as useless ones. By using the PPS-index tree, the search time will get significantly reduced.In Figure7, the vertex variable “?Z” has two-direction inbound predicates, “<advisor,teacherOf>” and “<takesCourse>”. According to a study [23], all incoming predicate paths with incoming predicates less than 3 were calculated, including “<advisor,teacherOf>”, “<teacherOf>”, and “<takesCourse>”. The intermediate results were filtered by the longest incoming predicate path index in each direction, and finally, the result sets traversed are merged, as shown in Figure 8.Figure 7
SPARQL query graph.Figure 8
Combined results.A prefix tree structure storing the PPS-indices is similar to an inverted index in information retrieval. Each inverted predicate path can be regarded as a word in the inverted index, and the vertex list is equivalent to the document Id sorted in the inverted index. There are many repeated parts in PPS-indices, as shown in Figure5: <p1,p2,p3>, <p2,p1,p1>, <p2,p1,p2>, ⋯. All of them contain p1,p2 without the prefix tree; more storage units are needed to store duplicate path information. Therefore, by the prefix tree, the same predicate prefix can be stored only once, which can save space. By PPS-indices, the vertex list corresponding to the specified predicate path could be quickly found, so as to filter the redundant vertices. For the length of the predicate path, the maximum value of 3 is used according to the empirical value [23]. In order to compress and store data better, the actual vertex Id number is not stored, but the vertex Id number difference is similar to that of the compressed triples [4, 5].The SPARQL query includes a join whose predicate is a variable, as shown in Figure9. One method is to remove all paths which include the predicate variables. Although this is relatively simple, the ability of predicate path filtering is limited. The other method is to consider the predicate variable as a special predicate and to replace it with pv, which is a bit like the wildcard “?”. In Figure 9, the predicate path of all incoming edges of the vertex “?v4” is <p1,pv>, <p2>, and <pv>; replace “?p” with pv, where VertexListp1,pv is the set of vertices corresponding to the predicate path, p1⟶pv, and the first predicate of the predicate path was p1. We adopted the second method to deal with the predicate path containing predicate variables.Figure 9
A SPARQL query with a predicate variable.Our two-phase query processing algorithm is shown in Algorithm1. The algorithm is mainly divided into three steps. In the first step, the input SPARQL query is analyzed and divided into blocks (steps 1-2). In the second step for each triple pattern in the block, ?s,p,o is filtered by the selectivity and getVariableSelectivity (steps 3-5), where the selectivity function reorders the joins of the form ?S,P,O, and the current query mode with the least join cost in the query pattern will be executed in order to reduce the amount of intermediate results generated in the query process as much as possible. In the third step, the remaining triples are filtered using PPS-indices Trie (step 6-9) which is the second round filtering of intermediate results. Because the predicate path considers at least one triple pattern, the predicate path filtering can filter out more intermediate results than the single triple pattern. The final merged result output is displayed in step 10. The join structure types of SPARQL are generally classified into star structure, string structure, and mixed structure type. In this study, the above types of SPARQL queries are selected for comparison experiments from the four datasets, LUBM, YAGO2, SPARQL benchmark dataset (SP2B), and DBpedia SPARQL benchmark dataset (DBSPB). From the experiments on all types of SPARQL queries, we verify the correctness and effectiveness of the two-phase algorithm proposed. The time complexity of the algorithm is mainly determined by step 6 to step 9, which is O (n∗e−), where n is the number of variables in the input SPARQL query, and e− is the average inbound edge of each variable in the SPARQL query. The results indicate that the time of the algorithm is affected by the number of variables in the SPARQL query and the number of incoming edges of the variables.Algorithm 1: Two-phase algorithm for SPARQL query processing.
Input:SPARQL queries,queryStr, Trie;Output:combined Results;1 ParsequeryStr;2 BlockqueryStr into n blocks;3Fori ←0 to n-14  Filter out joins with (?s, p, o) by getVariableSelectivity(queryStr.variable[i]) in order;5endFor6For each variable v ϵVariables7filterList ← getVertexList(Trie,v);8  Merge results usingfilterList; // By using Trie, useless vertices are filtered by the longest predicate path index of each variable and then the results will be combined.9endFor10Output Results;


### 2.5. Evaluation

Public datasets, LUBM, YAGO2, SPARQL benchmark dataset (SP2B) [33], and DBpedia SPARQL benchmark dataset (DBSPB) [33], were utilized for the study. The open RDF-3X [4, 5] system (version 0.3.5) and TripleBit [27] were used for the evaluation experiments. Through the generator of LUBM, LUBM datasets of 10,000 universities are obtained. Table 4 shows the statistical information of these four datasets. Among them, YAGO2 contains 94 predicates, LUBM and SP2B contain 17,77 predicates, respectively, and DBSPB contains 39,675 predicates. DBSPB is a merger of multiple domain datasets, YAGO2 is a merger of heterogeneous datasets WordNet and Wikipedia, and LUBM and SP2B are descriptions of the relationship between similar domains. The size of the PPS-indices with a maximum length of 3 is shown in Table 5, including the number of vertices pointed to by the predicate path sequence index and the size of the entire index. Because the LUBM dataset exhibits the characteristics of a single structured model, it contains fewer vertices.Table 4
Statistics for datasets.
DatasetsThe number of predicatesThe number of triplesSize (GB)YAGO294195,948,2547.8LUBM171,243,781,34572DBSPB39,675183,000,00025SP2B771,399,000,000123Table 5
Size of PPS-index.
Yago2LUBMDBSPBSP2BThe number of vertex list (#)24.977132145,157120,065Size (GB)0.781.457.0323.86We employed the top nine queries Q1-Q9 in the benchmark query of the LUBM dataset in the comparative experiments. Tables6 and 7 show the number of intermediate results for queries Q1-Q9. From the comparison, it was revealed that a simple structure query or a complex structure query such as Q2 and Q9 generated fewer intermediate results than RDF-3X. For queries Q1 and Q5, the number of intermediate results by our method was relatively close to TripleBit, because no filterable predicate path index was found. In future work, we will try to continuously update the PPS-indices. From YAGO2, we selected 10 queries each with a predicate path sequence length of 3-7 and calculated the average query execution time and the number of intermediate results.Table 6
Evaluation results of LUBM for Q1-Q5.
Q1Q2Q3Q4Q5RDF-3x392,688,864424,747,108334,234,879245,123,469575,821,432Two-phase212,452,134234,876,67301,567,121135,877,334376,223,562TripleBit212,404,452372,245,356313,458,135148,356,765376,278,263Table 7
Evaluation results of LUBM for Q6-Q9.
Q6Q7Q8Q9RDF-3x659,738,158543,786,113380,103,352667,922,234Two-phase415,234,133324,455,729145,235,246576,245,458TripleBit455,673,778362,135,567208,356,113621,472,876We compared the proposed methods with RDF-3X and TripleBit. From Figure10, it can be observed that except for the predicate path sequence length of 3, the execution time and the number of intermediate results were generally lower than those of RDF-3X, and the execution time and the amount of intermediate results increased slowly with the variation in the length of the predicate path. We noted an increase in the time curves of our method, RDF-3X, and TripleBit (Figure 10), with an increase in the predicate path length. Although our approach did not outperform TripleBit as a whole (Figure 10), when the path length was 3 or 4, our curve was very close to that of TripleBit. Furthermore, the execution time curve was better than that of RDF-3X and TripleBit. TripleBit chooses the query pattern corresponding to the smallest selective variable, to reduce the size of the intermediate result set in the query process. The main reason for the performance degradation of TripleBit is that the query contains more joins or accesses more index blocks. As a result, for queries with a small number of predicate path lengths, the filtering effect was similar to that of TripleBit. For queries with a long predicate path, our proposed method outperformed TripleBit.Figure 10
Evaluation results for YAGO2: execution time (a) and cardinality of intermediate results (b).
(a)(b)In order to verify that our method is applicable to various RDF datasets, queries Q10-Q13 and Q14-Q17 were constructed for the datasets DBSPB and SP2B, which are shown in Table8. These queries consist of 4 to 5 join times and have a long predicate path. The execution time of the query is shown in Figures 11(a) and 10(b). We found that except queries Q10 and Q17, the query execution time achieved in these two datasets was better than that of RDF-3X and TripleBit. The execution time of queries Q11, Q12, Q13, Q15, Q14, and Q16 in Table 8 is significantly less than that of RDF-3X and TripleBit. Since we filtered out a large number of useless intermediate results using the PPS-indices, TripleBit dynamically calculated the optimal selective triple pattern for queries with more joins and accessed more index blocks. However, for queries Q10 and Q17, although there was no TripleBit with high execution efficiency, there was no significant difference. Additionally, no filterable predicate paths were found in the PPS-indices.Table 8
SPARQL queries for DBSPB and SP2B.
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>PREFIX dbpprop:http://dbpedia.org/property/PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>PREFIX dbpowl:http://dbpedia.org/ontology/PREFIX geo:http://www.w3.org/2003/01/geo/wgs84_pos#PREFIX foaf:http://xmlns.com/foaf/0.1/PREFIX dc:<http://purl.org/dc/elements/1.1/>PREFIX dcterms:http://purl.org/dc/terms/PREFIX bench:http://localhost/vocabulary/bench/PREFIX swrc:<http://swrc.ontoware.org/ontology#>Q10 SELECT ?x ?y ?z ?m ?n ?p ?q ?r ?s ?t WHERE{?x dbpprop:ground ?y. ?x foaf:homepage ?z. ?m rdfs:label ?n. ?m dbpowl:postalCode ?p. ?m geo:lat ?q. ?m geo:long ?r. ?y dbpowl:location ?m. ?y foaf:homepage ?s. ?t dbpprop:clubs ?x}Q11 SELECT ?x ?y ?z ?m ?n ?p ?q ?s ?t WHERE{?x rdf:type dbpowl:Person. ?x dbpprop:name ?z. ?n rdfs:label ?p. ?x dbpprop:placeOfBirth ?m. ?n dbpprop:isbn ?t. ?n dbpprop:author ?x. ?q dbpprop:author ?s. ?s rdfs:label ?y. ?n dbpprop:precededBy ?q. ?s dbpprop:name ?z. ?s dbpprop:placeOfBirth ?m}Q12 SELECT ?x ?y ?z ?m ?n ?p ?q ?r ?s WHERE{?x foaf:name ?y. ?x rdfs:comment ?z. ?x rdf:type ?m. ?x dbpprop:series ?n. ?n dbpowl:starring ?p. ?p rdf:type ?s. ?q dbpowl:starring ?p. ?r dbpowl:previousWork ?q}Q13 SELECT ?x ?y ?z ?m ?n ?p ?q ?r ?s WHERE{?x foaf:name ?y. ?x rdfs:comment ?z. ?x rdf:type ?m. ?x dbpprop:series ?n. ?n dbpowl:starring ?p. ?p rdf:type ?s. ?q dbpowl:starring ?p. ?r dbpowl:previousWork ?q}Q14 SELECT ?x ?y ?z ?m ?n ?p ?q ? r ?s ?t WHERE{?x dcterms:references ?y. ?x a bench:Inproceedings. ?y rdf:_1 ?z. ?y rdf:_2 ?m. ?z dcterms:references ?n. ?n rdf:_1 ?p. ?n rdf:_2 ?q. ?m dcterms:references ?r. ?r rdf:_1 ?s. ?r rdf:_2 ?t}Q15 SELECT ?x ?y ?z WHERE{?x swrc:editor ?y. ?z dc:creator ?y. ?z dcterms:partOf ?x}Q16 SELECT ?x ?y ?z ?m ?n ?p ?q WHERE{?x dc:creator ?y. ?y foaf:name ?z. ?x dc:title ?m. ?x bench:abstract ?n. ?x dcterms:references ?p. ?p rdf:_50 ?q}Q17 SELECT ?x ?y ?z ?m ?n ?p ?q WHERE{?x swrc:editor ?y. ?z swrc:editor ?y. ?y foaf:name ?m. ?x dc:creator ?y. ?x dc:title ?n. ?x dcterms:references ?p. ?p rdf:_10 ?q}Figure 11
Execution time: DBSPB(a) and SP2B(b).
(a)(b)


## 2.1. SPARQL and Query Execution Plan

SPARQL has been recommended by the W3C as the standard query language for RDF data. It is a query for obtaining the results through matching triples on the RDF data [28]. A basic SPARQL query mainly consists of two parts, the SELECT clause and the WHERE clause. Among them, “pattern1”, “pattern2”, etc. are all triple patterns, and the operator “.” connects the two triple patterns. Each triple pattern is composed of a subject, predicate, and object, and these three items are either text or variables. The query uses the text to represent the known and employs variables to denote the unknown, as shown in the query example:SELECT ?variable1 ?variable2 … WHERE { pattern1. pattern2…}The following is the ninth query example Q9 from the LUBM benchmark. This example queries all students, teachers, and courses and satisfies that the courses of students are taught by the teacher and the teacher is the students’ instructor. Among them, the first two lines “rdf” and “ub” are all prefixes, and “?Xrdf:typeub:Student” is a triple pattern. The SPARQL queries processed in this study include triple patterns with the predicate as a variable (see Section 2.4).PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>PREFIX ub:<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#>SELECT ?X ?Y ?ZWHERE{?X rdf:type ub:Student.?Y rdf:type ub:Faculty.?Z rdf:type ub:Course.?X ub:advisor ?Y.?Y ub:teacherOf ?Z.?X ub:takesCourse ?Z }A query execution plan for the above example is shown in Figure1, which is an operation tree. A SPARQL query includes multiple joins, so an improper query join order can produce large amounts of redundant intermediate results. As shown in Table 1, the third and fourth rows present the amount of intermediate results during the join process. The fourth row “T4⋈T5⋈T6” join produces 600,000 intermediate results, but only 2000 of the final results, at least 598,000 redundant intermediate results, are generated in this process. As a result, the size of the result set of each connection affects the next join operation. Therefore, in order to reduce the intermediate results as much as possible, in the first stage, it is important to adjust the join sequence and put the join producing fewer intermediate results in the front. In the second stage, the redundant vertices of the remaining triple patterns are filtered out using predicate path sequence indices (see Section 2.4 for details).Figure 1
A query plan for Q9.Table 1
The cardinality of intermediate results.
Different joinsThe cardinality of intermediate resultsT1⋈T2⋈T3⋈T4⋈T5⋈T62000T1⋈T2⋈T31,000,000T4⋈T5⋈T6600,000


## 2.2. SPARQL Query Optimization

We employed the SPARQL queries as graphs instead of trees. The system process flow is shown in Figure2. In the first stage, the SPARQL query graph is divided into blocks, reordered according to the cost of each join within the block, and partial joins are executed. The cost is estimated based on the amount of intermediate results produced by the joins in the second stage, wherein we used the PPS-indices that were built beforehand to refine the triples. This process is somewhat similar to the filtering of the predicate path [23]. While filtering, the longest PPS-indices were employed for matching the filtering instead of all predicate paths within a path length range. This avoided excessively double calculation, so as to improve the query efficiency (see Section 2.4).Figure 2
The system process flow.The query execution plan is a graph instead of a tree, which is convenient for reusing the results of the intrablock joins. Figure3(a) shows the Q9 query graph. In the first stage, the SPARQL query graph is divided into different blocks containing the same join variables. Figure 3(b) is a part of the Q9 query graph. According to the triple pattern containing the same join variable, “?X” are classified into one block. Of course, a triple pattern with two variables, such as “?Xub:advisor?Y”, can be classified into one block by the variable “?X”, or it can be classified into one block by the variable “?Y”. Each block belongs to a star join. A star denotes a join between two subjects. For instance, in the above example, “T1⋈T2” and “T1⋈T3” all belong to the star join, which is the ternary description of the predicate in the star join. The group mode (including a variable) is reordered according to selectivity, and partial joins are performed to filter out the useless intermediate results.Figure 3
A query graph for Q9 and one of its blocks: a query graph for Q9 (a) and a block for Q9 query graph (b).
(a)(b)


## 2.3. Estimation of Selectivity

The selectivity is based on the number of triples of the matching join,Tn, as shown in formula (1), where the degree of selectivity is inversely proportional to the number of matched triples. That is, the number of corresponding matched triples is larger, and the degree of selection is smaller. For example, if #T1<#T2<#T3, then selT1>selT2>selT3. In order to save the space and time, the calculation of SELECTIVITY (selection degree) generally contains at most one query variable triple pattern, and the most frequent triple pattern is ?s,p,o. Given the object o and the predicate p of a triple, the value of the subject s in the corresponding triple can be obtained.
(1)SELECTIVITY=minimumselT1,selT2,⋯,selTn.We built an OPS (object, predicate, and subject) index, as presented in [6]. By specifying the object and predicate, the corresponding subject Id list and cardinals of matching triples were obtained, so as to complete the optimal execution within the block. The plan and structure are shown in Table 2. The joins with a small number of connections were performed, so as to minimize the unnecessary joins.Table 2
OPS index.
ObjectPredicateSubjectId“FullProfessor0”Name1(FullProfessor0)“University0”Name2(University0)“Department0”Name3(Department0)


## 2.4. Predicate Path Sequence Indices (PPS-Indices)

In the second stage, we construct the predicate path sequence indices to filter the remaining joins in the second stage. PPS-indices were extracted from large-scale RDF data graphs by the depth first search (DFS). The definition of the RDF data graph was adopted according to the study [29], as shown by Definition 1. We defined an RDF entity-relationship graph for building the PPS-indices, as defined in Section 2.Definition 1 (RDF graph).
An RDF data graph is a tuple (V,L,E), where V is a finite set of vertices, VE represents entity vertices, VC represents class vertices, and VV represents the data vertices, forming a disjoint union VE⊎VC⊎VV. L is a limited set of edge labels, L=LR⊎LAtype,subclass, where LR represents the edge between entities and LA represents the edge between entities and data values. E is a finite edge set; the form of the edge is ev1,v2, where v1,v2∈VE,e∈L, only v1,v2∈VE,e∈LR; e∈LA if and only if v1∈VE and v2∈VV; e=type only when v1∈VE and v2∈Vc; and e=subclass only when v1,v2∈VC.Definition 2 (RDF entity-relationship graph,G′).
An RDF entity relationship graphG′ is a triple (V′,L′,E′), where vertex V′=VE, edge label L′=LR, and E′⊂E,E′ connects the two entity vertices. VE represents a collection of entity vertices (e.g., IRIs). Only when the edge ev1,v2∈E′and v1,v2∈VE exist in the RDF data does the edge ev1,v2∈VE exist in the RDF entity relationship graph.PPS-indices are based on the RDF entity relationship graph, excluding the data value and type triples, as shown in Figure4. The triples containing values are processed in the first stage.Definition 3 (inbound predicate path sequence).
The inbound predicate path is a sequence of triple predicates. If the terminal vertex of a path ise, it is said to be an inbound predicate path of e.Figure 4
RDF entity relationship graph.For example, for the join of “?Xub:advisor?Y.?Yub:teacherOf?Z” in Q9, there is an inbound predicate path sequence of the variable “?Z”, “ub:advisor⟶ub:teacherOf”. Table 3 shows the list of vertices pointed to by the predicate path index in Figure 4. Through such a list of vertices, useless intermediate vertices can be filtered out firstly, thereby avoiding more unnecessary join operations. For example, if there is a link in a SPARQL query, “?n1p1?n2.?n2.p2?n3.?n3?p3?n4”, the predicate path “<p1,p2,p3>” can be found that contains the vertex Id list “8, 9” for filtering the result set, without having to merge a large number of intermediate result sets.Table 3
Vertex lists for predicate path indices.
Path lengthPredicate path sequenceVertex Id lists1<p1>2, 5, 6, 12<p2>2, 3, 7, 9<p3>4, 7, 8, 9, 10, 112<p1,p2>2, 3, 7<p2,p1>5<p2,p2>3<p2,p3>4, 8, 9<p3,p1>5<p3,p2>93<p1,p2,p3>8, 9<p2,p1,p1>6<p2,p1,p2>7<p2,p3,p3>11<p3,p1,p2>2, 7<p3,p1,p3>10We obtained ann edge predicate sequence using the DFS algorithm. All bold edges in Figure 5 form a searching tree. The searching order of each vertex is marked below it. It can be seen from Figure 6 that the order of being searched for forward edges is 1,2, 2,3, and 2,4. We specify that for any vertex v′, all of its backward edges should be behind the forward edge that points to v′. For vertex 3, its backward edge 3,1 should appear after 2,3. Among the backward edges from the same vertex, an order is enforced: given vertex Id i and its two backward edges, i,j,i,k; if j<k, then edge i,j will appear before edge i,v. Thus, we obtain the ordering of edges in the RDF data graph. Based on the above order, a complete edge sequence is formed (Figure 5) as <1,2,2,3,3,1,2,4>. We call this sequence the DFS code. Since there are a lot of different searching trees in a graph, each of which can form a DFS sequence code; a lexicographic order was designed to order the DFS code [30, 31]. We denote a labeled edge by its predicate without vertices. Thus, the edge predicate path sequence of Figure 5 can be written as <p1,p1,p2,p2>.Figure 5
DFS code generation.Figure 6
PPS-index tree.A PPS-index tree storing PPS-indices is shown in Figure6, where each vertex stands for a sequential segment (a minimal sequence code). Here, two discriminative segments f1=<p1> and f9=<p1,p2,p1> are kept in the PPS-index tree. Pi is used to denote predicate of edges in DFS codes. Though segments f2,f3 on level 1 are not the discriminative segments, f2 and f3 have to be kept for connecting the vertices f5, f6, and f7.The PPS-index tree is a prefix that keeps all discriminative segments with sizen in level n (segments with size 0 denote subgraphs that have one vertex and no edges). This discriminative predicate path is adapted from the concept in an earlier study [32]. In this prefix tree, if t is a prefix of t′, t is an ancestor of t′. All black vertices represent the discriminative segments, and white vertices represent the intermediate vertices of the whole PPS-index tree. In each black node, fi denotes a list of predicate path sequence; for instance, f1 is <p1> and f5 is <p2,p1>. PPS-indices store the discriminative segments as well as useless ones. By using the PPS-index tree, the search time will get significantly reduced.In Figure7, the vertex variable “?Z” has two-direction inbound predicates, “<advisor,teacherOf>” and “<takesCourse>”. According to a study [23], all incoming predicate paths with incoming predicates less than 3 were calculated, including “<advisor,teacherOf>”, “<teacherOf>”, and “<takesCourse>”. The intermediate results were filtered by the longest incoming predicate path index in each direction, and finally, the result sets traversed are merged, as shown in Figure 8.Figure 7
SPARQL query graph.Figure 8
Combined results.A prefix tree structure storing the PPS-indices is similar to an inverted index in information retrieval. Each inverted predicate path can be regarded as a word in the inverted index, and the vertex list is equivalent to the document Id sorted in the inverted index. There are many repeated parts in PPS-indices, as shown in Figure5: <p1,p2,p3>, <p2,p1,p1>, <p2,p1,p2>, ⋯. All of them contain p1,p2 without the prefix tree; more storage units are needed to store duplicate path information. Therefore, by the prefix tree, the same predicate prefix can be stored only once, which can save space. By PPS-indices, the vertex list corresponding to the specified predicate path could be quickly found, so as to filter the redundant vertices. For the length of the predicate path, the maximum value of 3 is used according to the empirical value [23]. In order to compress and store data better, the actual vertex Id number is not stored, but the vertex Id number difference is similar to that of the compressed triples [4, 5].The SPARQL query includes a join whose predicate is a variable, as shown in Figure9. One method is to remove all paths which include the predicate variables. Although this is relatively simple, the ability of predicate path filtering is limited. The other method is to consider the predicate variable as a special predicate and to replace it with pv, which is a bit like the wildcard “?”. In Figure 9, the predicate path of all incoming edges of the vertex “?v4” is <p1,pv>, <p2>, and <pv>; replace “?p” with pv, where VertexListp1,pv is the set of vertices corresponding to the predicate path, p1⟶pv, and the first predicate of the predicate path was p1. We adopted the second method to deal with the predicate path containing predicate variables.Figure 9
A SPARQL query with a predicate variable.Our two-phase query processing algorithm is shown in Algorithm1. The algorithm is mainly divided into three steps. In the first step, the input SPARQL query is analyzed and divided into blocks (steps 1-2). In the second step for each triple pattern in the block, ?s,p,o is filtered by the selectivity and getVariableSelectivity (steps 3-5), where the selectivity function reorders the joins of the form ?S,P,O, and the current query mode with the least join cost in the query pattern will be executed in order to reduce the amount of intermediate results generated in the query process as much as possible. In the third step, the remaining triples are filtered using PPS-indices Trie (step 6-9) which is the second round filtering of intermediate results. Because the predicate path considers at least one triple pattern, the predicate path filtering can filter out more intermediate results than the single triple pattern. The final merged result output is displayed in step 10. The join structure types of SPARQL are generally classified into star structure, string structure, and mixed structure type. In this study, the above types of SPARQL queries are selected for comparison experiments from the four datasets, LUBM, YAGO2, SPARQL benchmark dataset (SP2B), and DBpedia SPARQL benchmark dataset (DBSPB). From the experiments on all types of SPARQL queries, we verify the correctness and effectiveness of the two-phase algorithm proposed. The time complexity of the algorithm is mainly determined by step 6 to step 9, which is O (n∗e−), where n is the number of variables in the input SPARQL query, and e− is the average inbound edge of each variable in the SPARQL query. The results indicate that the time of the algorithm is affected by the number of variables in the SPARQL query and the number of incoming edges of the variables.Algorithm 1: Two-phase algorithm for SPARQL query processing.
Input:SPARQL queries,queryStr, Trie;Output:combined Results;1 ParsequeryStr;2 BlockqueryStr into n blocks;3Fori ←0 to n-14  Filter out joins with (?s, p, o) by getVariableSelectivity(queryStr.variable[i]) in order;5endFor6For each variable v ϵVariables7filterList ← getVertexList(Trie,v);8  Merge results usingfilterList; // By using Trie, useless vertices are filtered by the longest predicate path index of each variable and then the results will be combined.9endFor10Output Results;


## 2.5. Evaluation

Public datasets, LUBM, YAGO2, SPARQL benchmark dataset (SP2B) [33], and DBpedia SPARQL benchmark dataset (DBSPB) [33], were utilized for the study. The open RDF-3X [4, 5] system (version 0.3.5) and TripleBit [27] were used for the evaluation experiments. Through the generator of LUBM, LUBM datasets of 10,000 universities are obtained. Table 4 shows the statistical information of these four datasets. Among them, YAGO2 contains 94 predicates, LUBM and SP2B contain 17,77 predicates, respectively, and DBSPB contains 39,675 predicates. DBSPB is a merger of multiple domain datasets, YAGO2 is a merger of heterogeneous datasets WordNet and Wikipedia, and LUBM and SP2B are descriptions of the relationship between similar domains. The size of the PPS-indices with a maximum length of 3 is shown in Table 5, including the number of vertices pointed to by the predicate path sequence index and the size of the entire index. Because the LUBM dataset exhibits the characteristics of a single structured model, it contains fewer vertices.Table 4
Statistics for datasets.
DatasetsThe number of predicatesThe number of triplesSize (GB)YAGO294195,948,2547.8LUBM171,243,781,34572DBSPB39,675183,000,00025SP2B771,399,000,000123Table 5
Size of PPS-index.
Yago2LUBMDBSPBSP2BThe number of vertex list (#)24.977132145,157120,065Size (GB)0.781.457.0323.86We employed the top nine queries Q1-Q9 in the benchmark query of the LUBM dataset in the comparative experiments. Tables6 and 7 show the number of intermediate results for queries Q1-Q9. From the comparison, it was revealed that a simple structure query or a complex structure query such as Q2 and Q9 generated fewer intermediate results than RDF-3X. For queries Q1 and Q5, the number of intermediate results by our method was relatively close to TripleBit, because no filterable predicate path index was found. In future work, we will try to continuously update the PPS-indices. From YAGO2, we selected 10 queries each with a predicate path sequence length of 3-7 and calculated the average query execution time and the number of intermediate results.Table 6
Evaluation results of LUBM for Q1-Q5.
Q1Q2Q3Q4Q5RDF-3x392,688,864424,747,108334,234,879245,123,469575,821,432Two-phase212,452,134234,876,67301,567,121135,877,334376,223,562TripleBit212,404,452372,245,356313,458,135148,356,765376,278,263Table 7
Evaluation results of LUBM for Q6-Q9.
Q6Q7Q8Q9RDF-3x659,738,158543,786,113380,103,352667,922,234Two-phase415,234,133324,455,729145,235,246576,245,458TripleBit455,673,778362,135,567208,356,113621,472,876We compared the proposed methods with RDF-3X and TripleBit. From Figure10, it can be observed that except for the predicate path sequence length of 3, the execution time and the number of intermediate results were generally lower than those of RDF-3X, and the execution time and the amount of intermediate results increased slowly with the variation in the length of the predicate path. We noted an increase in the time curves of our method, RDF-3X, and TripleBit (Figure 10), with an increase in the predicate path length. Although our approach did not outperform TripleBit as a whole (Figure 10), when the path length was 3 or 4, our curve was very close to that of TripleBit. Furthermore, the execution time curve was better than that of RDF-3X and TripleBit. TripleBit chooses the query pattern corresponding to the smallest selective variable, to reduce the size of the intermediate result set in the query process. The main reason for the performance degradation of TripleBit is that the query contains more joins or accesses more index blocks. As a result, for queries with a small number of predicate path lengths, the filtering effect was similar to that of TripleBit. For queries with a long predicate path, our proposed method outperformed TripleBit.Figure 10
Evaluation results for YAGO2: execution time (a) and cardinality of intermediate results (b).
(a)(b)In order to verify that our method is applicable to various RDF datasets, queries Q10-Q13 and Q14-Q17 were constructed for the datasets DBSPB and SP2B, which are shown in Table8. These queries consist of 4 to 5 join times and have a long predicate path. The execution time of the query is shown in Figures 11(a) and 10(b). We found that except queries Q10 and Q17, the query execution time achieved in these two datasets was better than that of RDF-3X and TripleBit. The execution time of queries Q11, Q12, Q13, Q15, Q14, and Q16 in Table 8 is significantly less than that of RDF-3X and TripleBit. Since we filtered out a large number of useless intermediate results using the PPS-indices, TripleBit dynamically calculated the optimal selective triple pattern for queries with more joins and accessed more index blocks. However, for queries Q10 and Q17, although there was no TripleBit with high execution efficiency, there was no significant difference. Additionally, no filterable predicate paths were found in the PPS-indices.Table 8
SPARQL queries for DBSPB and SP2B.
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>PREFIX dbpprop:http://dbpedia.org/property/PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>PREFIX dbpowl:http://dbpedia.org/ontology/PREFIX geo:http://www.w3.org/2003/01/geo/wgs84_pos#PREFIX foaf:http://xmlns.com/foaf/0.1/PREFIX dc:<http://purl.org/dc/elements/1.1/>PREFIX dcterms:http://purl.org/dc/terms/PREFIX bench:http://localhost/vocabulary/bench/PREFIX swrc:<http://swrc.ontoware.org/ontology#>Q10 SELECT ?x ?y ?z ?m ?n ?p ?q ?r ?s ?t WHERE{?x dbpprop:ground ?y. ?x foaf:homepage ?z. ?m rdfs:label ?n. ?m dbpowl:postalCode ?p. ?m geo:lat ?q. ?m geo:long ?r. ?y dbpowl:location ?m. ?y foaf:homepage ?s. ?t dbpprop:clubs ?x}Q11 SELECT ?x ?y ?z ?m ?n ?p ?q ?s ?t WHERE{?x rdf:type dbpowl:Person. ?x dbpprop:name ?z. ?n rdfs:label ?p. ?x dbpprop:placeOfBirth ?m. ?n dbpprop:isbn ?t. ?n dbpprop:author ?x. ?q dbpprop:author ?s. ?s rdfs:label ?y. ?n dbpprop:precededBy ?q. ?s dbpprop:name ?z. ?s dbpprop:placeOfBirth ?m}Q12 SELECT ?x ?y ?z ?m ?n ?p ?q ?r ?s WHERE{?x foaf:name ?y. ?x rdfs:comment ?z. ?x rdf:type ?m. ?x dbpprop:series ?n. ?n dbpowl:starring ?p. ?p rdf:type ?s. ?q dbpowl:starring ?p. ?r dbpowl:previousWork ?q}Q13 SELECT ?x ?y ?z ?m ?n ?p ?q ?r ?s WHERE{?x foaf:name ?y. ?x rdfs:comment ?z. ?x rdf:type ?m. ?x dbpprop:series ?n. ?n dbpowl:starring ?p. ?p rdf:type ?s. ?q dbpowl:starring ?p. ?r dbpowl:previousWork ?q}Q14 SELECT ?x ?y ?z ?m ?n ?p ?q ? r ?s ?t WHERE{?x dcterms:references ?y. ?x a bench:Inproceedings. ?y rdf:_1 ?z. ?y rdf:_2 ?m. ?z dcterms:references ?n. ?n rdf:_1 ?p. ?n rdf:_2 ?q. ?m dcterms:references ?r. ?r rdf:_1 ?s. ?r rdf:_2 ?t}Q15 SELECT ?x ?y ?z WHERE{?x swrc:editor ?y. ?z dc:creator ?y. ?z dcterms:partOf ?x}Q16 SELECT ?x ?y ?z ?m ?n ?p ?q WHERE{?x dc:creator ?y. ?y foaf:name ?z. ?x dc:title ?m. ?x bench:abstract ?n. ?x dcterms:references ?p. ?p rdf:_50 ?q}Q17 SELECT ?x ?y ?z ?m ?n ?p ?q WHERE{?x swrc:editor ?y. ?z swrc:editor ?y. ?y foaf:name ?m. ?x dc:creator ?y. ?x dc:title ?n. ?x dcterms:references ?p. ?p rdf:_10 ?q}Figure 11
Execution time: DBSPB(a) and SP2B(b).
(a)(b)


## 3. Conclusion

In the present study, we proposed a two-phase SPARQL query processing solution. On the one hand, the join with the smallest number of joins was found through the calculation of the selectivity degree, and on the other hand, the PPS-indices were leveraged to prune away the redundant intermediate results. Although the PPS-indices consumed a certain amount of storage space, using space for time greatly improved the execution efficiency of the SPARQL queries. Furthermore, the proposed PPS-indices can be incrementally updated, with an update of the data. In addition, experiments using different datasets show that our solution is feasible and very effective in filtering the intermediate results. In the future work, the accuracy of the calculation of the selectivity of the triple connection will be further improved. In addition, we will try to filter the SPARQL queries with more complex structures through PPS-indices and apply the two-phase SPARQL query optimization to the parallel and distributed environments, such as MapReduce.



---

*Source: 4624856-2022-08-25.xml*