Patent ID: 8666969

Claim:
A method comprising: receiving, by a computing device, a first table join query to select information from two or more tables of a database, wherein the first table join query comprises a first group of table identifiers that identify the two or more tables; determining, by the computing device, whether the first table join query includes an outer join command; when the first table join query includes the outer join command: comparing, by the computing device, the first group of table identifiers and a second group of table identifiers that identify one or more pre-joined tables to determine whether each of the table identifiers of the first group matches at least one of the table identifiers of the second group; when each of the table identifiers of the first group matches at least one of the table identifiers of the second group, determining, by the computing device and for each table identifier of the first group, whether a predicate associated with the respective table identifier matches a predicate associated with a second table identifier of the second group, wherein the second table identifier matches the respective table identifier; responsive to determining that the predicate associated with the respective table identifier does not match a respectively ordered predicate associated with a second table identifier, determining whether at least two instances of the respective table identifier are included in a first order in the first table join query; responsive to determining that the at least two instances of the respective table identifier are included in the first order in the first table join query, determining by the computing device, that at least two predicates associated with the at least two instances of the respective table identifier are common to predicates associated with one or more instances of the second table identifier that are included in a second, different ordering of a query used to generate the one or more pre-joined tables; determining, by the computing device, that the at least two predicates are interchangeable such that the one or more pre-joined tables are usable to service the first table join query when the first order of the at least two predicates are swapped to the second order; and generating, by the computing device and based on the determination that the at least two predicates are interchangeable when the first order of the at least two predicates are swapped to the second order, a second table join query based at least in part on the first table join query, wherein the second table join query specifies at least one of the one or more pre-joined tables.