1. A method used for executing queries, the method comprising the steps of: storing first data that indicates one or more conditions under which output of a function remains constant; in response to receiving a query: computing a value of the function, and based on said first data, determining whether to store the value in a cache; in response to determining to store the value in the cache, storing in the cache the value in association with the function; after performing the step of storing, receiving a second query, wherein processing the second query requires the output of the function; and in response to receiving said second query, determining based on said first data whether to retrieve said value from said cache as the output of said function; and in response to determining to retrieve said value from said cache, retrieving said value from said cache.