Patent ID: 8589435

Claim:
A method of simplifying data flow in a database statement having a plurality of sequenced subexpressions, the method comprising: selecting one of a plurality of sequencing operations, wherein a first evaluation order for each of the plurality of sequenced subexpressions is specified in the selected sequencing operation; selecting one of the plurality of sequenced subexpressions according to the first evaluation order, wherein the plurality of sequenced subexpressions are specified through a WITH clause in the database statement and comprise at least one modification operation, wherein the modification operation modifies at least one table in a database; determining a first sequenced subexpression that includes a reference to the selected sequenced subexpression and affirms evaluation of the selected sequenced subexpression using a query graph model, wherein the first sequenced subexpression is subsequent to the selected sequenced subexpression according to the first evaluation order; searching the first sequenced subexpression for at least one driving reference to the selected sequenced subexpression, wherein the at least one driving reference forms a reference set; identifying table accesses in the selected sequenced subexpression to form a first access set; identifying all other table accesses in the database statement to form a second access set; identifying at least one conflicting table access between the first access set and the second access set, wherein each conflicting table access occurs when the database table is accessed at two separate conflicting points in the database statement, wherein a second evaluation order is determined for each conflicting table access between the first access set and the second access set, wherein a third evaluation order is determined between each access in the second access set and each driving reference in the reference set; determining whether each driving reference in the reference set has no table access in the second access set; determining whether each driving reference in the reference set and the identified table accesses in the selected sequenced subexpression are sequential with no identified conflicting table access; wherein in response to each driving reference having no table access in the second access set and each driving reference and the identified table accesses in the selected sequenced subexpression being sequential, modifying the database statement to remove a connection between the selected sequenced subexpression and the selected sequencing operation, wherein the connection includes the determined driving reference; and executing the modified database statement to retrieve data from the database.