Patent ID: 8073841

Claim:
A method comprising: evaluating a first database query that requests a plurality of requested fields from one or more XML documents stored in a database; wherein said query requests a respective value for each requested field of the plurality of requested fields and includes an XPATH expression that identifies said each requested field; wherein the evaluating includes: identifying the plurality of requested fields as correlated fields of a common XML fragment, the respective value of each requested field of said plurality of requested fields being contained within said common XML fragment; and determining whether one or more rewrite criteria are satisfied based on the correlated fields; and if said one or more rewrite criteria are satisfied, then rewriting said first database query to generate a rewritten query that includes a new data source that contains field values from said common XML fragment, wherein the field values from said common XML fragment include the respective value of said each requested field and at least one field value not requested by said database query; wherein the method is performed by one or more computing devices.