1. A method comprising steps of: receiving a query against a collection of XML documents stored in one or more tables of a database, wherein the query contains a row filter condition; determining that the query contains a set of path-based query operators that satisfy a set of criteria, wherein the set of path-based query operators comprises a first path-based query operator and a second path-based query operator; wherein satisfying said set of criteria requires that: a) the row output from the first path-based query operator is the row input to the second path-based operator; b) the row filter condition contains a path-based operand that references the row output from the second path-based query operator; and c) the output from the second path-based query operator is not returned in the results for the query; in response to determining that the query contains a set of path-based query operators that satisfy the criteria, rewriting the query by eliminating the second path-based query operator and re-writing the first path-based query operator to only return rows that satisfy the row filter condition; wherein the method is performed by one or more computing devices.