14. A computer-readable storage medium containing a program executable to perform an operation to speed up query execution involving user-defined functions, the operation comprising: receiving a query against data of a database, the query having at least one query condition invoking a first user-defined function using a field of the database as input to the first user-defined function, wherein the first user-defined function is configured to generate an output value based on an input value selected from a set of acceptable input values; for each of a plurality of input values from the set of acceptable input values, performing multiple trial executions of the first user-defined function using the respective input value and independent of any execution of the first user-defined function as part of query execution, in order to determine, based on results thereof, whether the first user-defined function satisfies a predefined deterministic criterion over the plurality of input values; upon determining, by operation of one or more computer processors when executing the program, that the first user-defined function satisfies a predefined deterministic criterion and that cached results are available for the first user-defined function, using the cached results in execution of the query against the data of the database to determine a corresponding query result, without executing the first user-defined function for at least one input value of the set of acceptable input values, that is stored in the field of the database, thereby speeding up execution of the query; and upon determining that the first user-defined function satisfies the predefined deterministic criterion and that the cached results are not available for the first user-defined function, executing the user-defined function on a plurality of field values stored for the field of the database, wherein at least a subset of the results obtained in executing the first user-defined function is cached.
14. A computer-readable storage medium containing a program executable to perform an operation to speed up query execution involving user-defined functions, the operation comprising: receiving a query against data of a database, the query having at least one query condition invoking a first user-defined function using a field of the database as input to the first user-defined function, wherein the first user-defined function is configured to generate an output value based on an input value selected from a set of acceptable input values; for each of a plurality of input values from the set of acceptable input values, performing multiple trial executions of the first user-defined function using the respective input value and independent of any execution of the first user-defined function as part of query execution, in order to determine, based on results thereof, whether the first user-defined function satisfies a predefined deterministic criterion over the plurality of input values; upon determining, by operation of one or more computer processors when executing the program, that the first user-defined function satisfies a predefined deterministic criterion and that cached results are available for the first user-defined function, using the cached results in execution of the query against the data of the database to determine a corresponding query result, without executing the first user-defined function for at least one input value of the set of acceptable input values, that is stored in the field of the database, thereby speeding up execution of the query; and upon determining that the first user-defined function satisfies the predefined deterministic criterion and that the cached results are not available for the first user-defined function, executing the user-defined function on a plurality of field values stored for the field of the database, wherein at least a subset of the results obtained in executing the first user-defined function is cached. 19. The computer-readable storage medium of claim 14 , wherein determining whether the first user-defined function satisfies the predefined deterministic criterion comprises: determining whether database tables accessed in executing the first user-defined function have been modified since a last execution of the first user-defined function.