1. A method for rewriting queries, the method comprising the computer implemented steps of: examining a first query that references a relation to which a second query evaluates; wherein the second query defines an array and a first set of formulas that reference the array; wherein the array has one or more dimensions; wherein the first query includes one or more predicates; wherein the second query does not include the one or more predicates; determining whether one or more criteria for rewriting said first query or said second query are satisfied; if said one or more criteria for rewriting said first query or said second query are satisfied, then making, based on said one or more predicates included in said first query, modifications to said second query involving one or more predicate conditions; and generating a rewritten query based on the modifications to said second query; wherein the steps of the method are performed by one or more computing devices.