A query engine (or optimizer) which supports database queries having
user-defined functions maintains historical execution data with respect
to each of multiple user-defined functions. The historical execution data
is dynamically updated based on query execution performance. When
executing a query having user-defined functions, the query engine uses
the historical execution data to predict an optimal evaluation ordering
for the query conditions and, preferably, to dynamically adjust the
evaluation order when appropriate. Preferably, the historical execution
data includes historical execution time of the user-defined function and
proportion of evaluated records which satisfied the query parameters.