Patent ID: 8239373

Claim:
A method comprising: computing a query expression against a collection of XML documents stored in one or more tables of a database by, at least in part, executing a plurality of row sources of a query execution plan created based on the query expression, said plurality of row sources including a first path-based row source based on a path expression and a second path-based row source based on a path expression; determining that the second path-based row source does not operate on rows that are generated by a first path-based row source; determining that the second path-based row source always generates a same set of rows upon execution; in response to determining that the second path-based row source does not operate on rows that are generated by the first path-based row source and that the second path-based row source always generates the same set of rows upon execution, enabling a cache for the second path-based row source; the first path-based row source generating a first row; in response to the first path-based row source generating the first row, the second path-based row source computing an expression and storing resulting data in the cache; after the first path-based row source generates the first row, the first path-based row source generating a next row; in response to the first path-based row source generating the next row, the second path-based row source retrieving data from said cache; and the second path-based row source generating rows based on said data from said cache; wherein the method is performed by one or more special-purpose computing devices.