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; retrieving one or more predefined statistics describing the user-defined function, wherein the one or more predefined statistics are based at least on output values of previous instances of executing the user-defined function; selecting, based at least on the one or more predefined statistics, a query plan for executing the database query; and outputting the selected query plan.