1. A computer-implemented method for selecting a query plan for executing a database query containing a user-defined function, comprising: receiving the database query containing the user-defined function, wherein the database query includes at least one input value associated with the user-defined function; retrieving one or more predefined statistics describing the user-defined function, wherein the one or more predefined statistics include input values and output values of previous instances of executing the user-defined function, and wherein the one or more predefined statistics include a hash table relating the input values to the output values; selecting, based at least on the one or more predefined statistics, a query plan for executing the database query, wherein selecting a query plan for executing the database query comprises: upon determining that at least one cardinality of the hash table is equal to or greater than a threshold level, selecting a query plan that executes the user-defined function; and upon determining that the at least one cardinality of the hash table is less than the threshold level, selecting a query plan that retrieves at least one user-defined function output value from the hash table that corresponds to the at least one input value received with the database query; and outputting the selected query plan.