1. A method comprising performing a machine-executed operation involving instructions, wherein the machine-executed operation is at least one of: A) sending said instructions over transmission media; B) receiving said instructions over transmission media; C) storing said instructions onto a machine-readable storage medium; and D) executing the instructions; wherein said instructions are instructions which, when executed by one or more processors, cause the one or more processors to perform the steps of: evaluating a first database query that requests fields from one or more XML documents stored in a database, wherein the evaluating includes: identifying as correlated fields a first plurality of fields that have a value contained in a XML fragment; 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 XML fragment, including certain values for said first plurality of fields and at least one field not requested by said database query.