Patent ID: 7840609

Claim:
A method for optimizing a query, comprising performing a machine-executed operation involving instructions, wherein said instructions are instructions which, when executed by one or more processors, cause the one or more processors to perform certain steps comprising: for each node in a set of nodes, creating an entry in an index; including, in the entry for each node, stored information that indicates whether there is either one node or more than one node at a path of the each node; receiving a first query against the set of nodes, wherein the first query specifies a function that receives a specified path as an argument; wherein the function is configured to: return a certain value when there is only one node at the specified path; and not return the certain value when there is more than one node at the specified path; transforming the first query into a second query, wherein the second query: does not include the function; includes a condition that is based on the stored information that indicates whether there is either one node or more than one node at the specified path; and includes operators operating on the index; and wherein the second query is configured to return an equivalent result as the first query.