Abstract:
A method of executing a distributed join query for a set of documents includes communication between a first server and a second server. In the first server, a first tuple list is generated from a first list of documents matching a precondition part of the query. A first set of value identifiers of attributes associated with the first list of documents is extracted from the first tuple list. A first set of dictionary keys is generated from the set of value identifiers. Then, the first set of dictionary keys is sent with a join condition attribute to a second server. In the second server, the first set of value identifiers is converted to a second set of value identifiers of attributes associated with the second server based on the set of dictionary keys. Then, a lookup of documents is performed based on the second set of value identifiers.

Description:
BACKGROUND  
       [0001]     An index is an ordered collection of numbers or character strings, or both, such that some numbers or character strings represent objects and other numbers or character strings represent information about these objects. For example, one form of index can be viewed as a table whose rows represent documents and whose columns represent attributes of these documents. Such a column in a table T can be referred to as T. attribute.  
         [0002]     Joins are a class of data-processing operations that may be performed on indexes. Joins are used to match documents from different indexes by finding matching values of certain attributes of these documents. As an illustrative example,  FIG. 1  shows two indexes A and B. In index A, documents represent customers and their attributes are surname, first name, and city. In index B, documents represent suppliers of certain goods and their attributes are company name and city. From indexes A and B, a table listing customers and companies in their home towns can be created. That is, the following SQL-like “join query” is evaluated: 
        SELECTA.surname, A.first_name, B.company FROM A, B where A.city=B.city        
 
         [0004]     To evaluate this join, these two indexes are joined by join attributes A.city and B.city. The corresponding documents from the two indexes are merged by matching their values of the join attributes. This yields the table of values shown in  FIG. 3 .  
         [0005]     Consider a distributed landscape in which indexes are hosted on separate machines. One problem is that the amount of network traffic required to compute such a distributed join may be the main factor limiting the performance achievable with a given join process. Conventional processes for computing the join may require network traffic proportional to the size of the join table. If, for two indexes, one index has N rows and the other index has M rows, then the join table may consist of as many as N*M rows, and has all the requested attributes from both tables.  
         [0006]     The problem is exacerbated in situations where indexes are too large for a single machine. Such indexes may be split up and stored on different servers. To process join queries over such distributed indexes, it may be necessary to transfer even more data over the network than in the case where each index has its own host. What is needed is a join method that minimizes network traffic.  
       SUMMARY  
       [0007]     This document presents methods and systems for calculating distributed joins, and for accelerating the execution of join queries in a distributed network landscape where the relevant indexes are stored on different hosts. The disclosed techniques minimize the amount of network traffic required. The methods and systems offer the benefits that only relatively small lists of integer values are transferred over the network, and value dictionaries from different indexes are fetched only once.  
         [0008]     In one embodiment, a method of executing a distributed join query for a set of documents includes communication between a first server and a second server. In the first server, the method includes generating a first tuple list from a first list of documents matching at least part of the query, and extracting, from the first tuple list, a first set of value identifiers of attributes associated with the first list of documents. The method further includes generating a first set of dictionary keys from the set of value identifiers, and sending the first set of dictionary keys with a join condition attribute to a second server. In the second server, the method includes converting the first set of value identifiers to a second set of value identifiers of attributes associated with the second server based on the set of dictionary keys, and performing a lookup of documents based on the second set of value identifiers.  
         [0009]     The details of one or more embodiments are set forth in the accompanying drawings and the description below. Other features, objects, and advantages will be apparent from the description and drawings, and from the claims.  
     
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0010]     These and other aspects will now be described in detail with reference to the following drawings.  
         [0011]      FIG. 1  illustrates two index tables.  
         [0012]      FIGS. 2A and 2B  illustrate the use of value dictionaries and the concept of value IDs.  
         [0013]      FIG. 3  illustrates the resulting table after performing a join query on these indexes.  
         [0014]      FIG. 4  is a flowchart of a method for executing a distributed join query between two indexes.  
         [0015]      FIG. 5  is a flowchart of a method for executing a distributed join query between three indexes.  
         [0016]      FIGS. 6A-6H  illustrate results of the method shown in  FIG. 4  for a specific query. 
     
    
       [0017]     Like reference symbols in the various drawings indicate like elements.  
       DETAILED DESCRIPTION  
       [0018]     A method for matching documents in a distributed data processing system is presented. The method includes a technique for calculating distributed joins for matching documents that minimizes the amount of network traffic required. In accordance with an embodiment, attribute values for a document are stored in a dictionary, as shown in  FIG. 2A . The dictionary is stored separately from any index that contains the corresponding attribute as a column. Such an index contains only the dictionary keys (referred to as “value IDs”) for the respective documents in the attribute columns. The value IDs are integer numbers that take much less space than the (possibly repeated) attribute values themselves.  FIG. 2B  illustrates the storage of dictionary keys in attribute columns.  
         [0019]     Equi-joins are a special type of join in which join attributes are compared for equality (i.e., “A.x=B.y”). For the sake of simplicity, only equi-joins are described herein. Provided that the value dictionaries are constructed such that the values are in ascending order before the keys are assigned (so that k 1 &lt;k 2  if v 1 &lt;v 2  for any two key/value pairs k 1 /v 1  and k 2 /v 2 ), those types of joins that involve comparing the join attributes using operators “not equal”, “less than”, etc. (e.g. “A.x&lt;B.x” or “A.x&gt;=B.x”) can also be evaluated using methods described herein, such as in steps  410 ,  506  and  506  described below. The relevant indexes should remain unmodified while an executed query is in progress. For each attribute used as a join attribute, there is a corresponding value dictionary, as described above, and joins are AND-connected to the other query parts. In an exemplary embodiment, each of the relevant indexes resides on a different index server A, B, C, . . . etc., and the final result is created on the logical server L.  
         [0020]     Attributes within an index are denoted as follows: Attribute x in index A is A.x, attribute y in index B is B.y . . . etc. Documents within an index are uniquely identified by internal document IDs: id A , id B , . . . which denote the document IDs of indexes A, B, . . . etc. Each dictionary key in a value dictionary is a value ID: for example, V A.X  denotes the value ID of attribute x in index A. Square brackets denote a list of values as follows: [id A ] stands for a list of document IDs from index A, for example. Square brackets enclosing multiple values denote tuples of values: [id A , id B , id C ] denotes a list of ordered triples (3-tuples) of document IDs from indexes A, B, and C, respectively. The elements can be reordered at no cost; for example, the tuple list [a, b] is obtained from [b, a] by swapping the columns.  
         [0021]     The function [V A.x ]→[V B.y ] converts value IDs for attribute A.x to value IDs for attribute B.y, using the respective value dictionaries. Value IDs from A.x that correspond to values missing in value dictionary for B.y are discarded. The function uniq(x) takes as its argument a list of values and removes from this list all duplicates, so that only unique values are present in the result. The function rfl(a, b) takes two lists as arguments and removes from list &lt;a&gt; those entries that are not present in list &lt;b&gt;. If one or both of these lists are tuples, then the lists are compared on the basis of the values in the respective first elements of the tuples.  
         [0022]      FIG. 4  is a flowchart of a method  400  for executing a join query between two index servers in a distributed server landscape. The query in method  400  is “A.x =B.y”. The intermediate results of method  400  when applied to the sample index in  FIG. 1  using the query “A.city=B.city” are graphically illustrated in  FIG. 6 . Evaluating the “=” part is accomplished as follows: A sends the value IDs to B, B sends those values back for which there was a match, and A removes from its list the values that were not found. After this, there are two lists which, when combined, yield a list of tuples of document IDs from A and B where the corresponding A.x&#39;s and B.y&#39;s match. To evaluate the query, the following steps are performed: at  402  server L sends the query part “A.x=B.y” to server A. At  404  server A generates a list [id A ] of all documents ( FIG. 6A ). From this list, server A creates the tuple list [id A , V A.x ]. At  406  ( FIG. 6B ) server A extracts the value IDs [V A.x ] from this list and sends the set uniq([V A.x ]) of valid dictionary keys for attribute A.x to server B together with the information that attribute B.y is to be used for the join.  
         [0023]     Server B performs the conversion [V A.x ]→[V B.y ] using the value dictionary of A.x, at  408  ( FIG. 6C ). For each resulting V B.y , at  410  ( FIG. 6D ) server B performs a lookup for the corresponding documents (the ones with this value ID), creates a list [id B , V B.y ], and converts it to a list [id B , V A.x ] using the value dictionary of A.x ( FIG. 6E ). From this list [id B , V A.x ], at  412  ( FIG. 6F ) server B extracts the resulting value IDs [V A.x ] (these are the values for which documents were found in index B), and sends the set uniq([V A.x ]) back to server A. Server B retains the list [V A.x , id B ].  
         [0024]     At  414  ( FIG. 6G ), server A uses the set uniq([V A.x ]) returned from server B to perform rfl([V A.x , id A ], [V A.x ]), thereby removing from the list [V A.x , id A ] those documents for which no corresponding documents were found in index B. Server A retains the resulting list [V A.x , id A ]. At  416  ( FIG. 6H ), server L retrieves list [id A , V A.x ] from server A and list [V A.x , id B ] from server B and matches the V A.x  values in the two lists to generate a list of tuples [id A , id B ] of document IDs id A  and id B  ( FIG. 61 ). This finds all the documents whose requested attributes are to be returned as the result of the join query.  
         [0025]      FIG. 5  extends the method above to more complex queries involving AND operators between the join parts. That is, in a query “A.x=B.y AND B.z=C.q,” the parts “A.x=B.y” and “B.z=C.q” are evaluated as outlined in  FIG. 4 . The results are then combined with AND. The “intermediate” result of evaluating the complete join query is a list of tuples of document IDs [id A , id B , id C ] which satisfy the given query (and for which the requested attributes are later retrieved). Thus, as a further example, consider a join query that refers to more than two indexes: SELECT A.a, B.b, C.c FROM A, B, C WHERE A.x=B.y AND B.z=C.q. In this example, it can be assumed that a query execution plan has been created, and that the parts of the query are to be executed in the order given in the query.  
         [0026]      FIG. 5  is a flowchart of a method  500  for executing a join query in a distributed server landscape having more than two index servers. At  502 , server L sends the query parts “A.x=B.y” and “B.z=C.q” to server A. At  504 , server A sends uniq([V A.x ]) to server B together with the information that attribute B.y is to be used for the join, plus the query part “B.z=C.q”. At  506 , server B performs [V A.x ]→[V B.y ] and creates the list [V A.x , id B ]. At  507 , [id B ] from this list is used to create [id B , V B.z ]. From this list, uniq([V B.z ]) is in turn sent to server C together with the information that attribute C.q is to be used for the join.  
         [0027]     At  508 , server C performs [V B.z ]→[V cq ] and creates and retains [V B.z , id C ]. From this list, uniq([V B.z ]) is sent back to server B. At  509 , server B uses this list to perform rfl([V B.z , id B ], [V B.z ]) to remove the value IDs that were not found on server C. The resulting [V B.z , id B ] is then used at  510  to perform rfl([id B , V A.x ], [id B , V B.z ]). Steps  507  through  510  are repeated (properly substituting the indexes and attributes) when queries with more indexes are to be evaluated.  
         [0028]     At  511 , the resulting list [id B , V A.x ] is used to send uniq([V A.x ]) back to server A. [V A.x , id B ] and [id B , V B.z ] are retained. At  512 , server A uses this list to perform rfl([V A.x , id A ], [V A.x ]) and retains the list [V A.x , id A ]. To assemble the final result, at  514  server L retrieves list [id A , V A.x ] from server A, lists [V A.x , id B ] and [id B , V B.z ] from server B, and list [V B.z , id C ] from server C. From these lists, server L creates the result tuples [id A , id B , id C ] along the chain [id A , V A.x ][V A.x , id B ][id B , V B.z ][V B.z , id C ] at  516 . Server L then retrieves the requested attributes A.a, B.b, and C.c from the respective indexes using the document Ids created in step  516 .  
         [0029]     Only relatively small lists of integer values are transferred over the network, such as [V A.x ], [id A , V A.x ], . . . etc. Value dictionaries from different indexes are fetched only once. They may then be retained locally (ideally in a least-recently-used (LRU) cache to limit the amount of memory used).  
         [0030]     Although a few embodiments have been described in detail above, other modifications are possible. The sequential order of execution shown in  FIGS. 4 and 5  are merely for clarity, and some operations may be performed in parallel, which is within the scope of the following claims.