1 ) An apparatus comprising: at least one processor; a memory coupled to the at least one processor; a deterministic user-defined function (UDF) residing in the memory and executed by the at least one processor, the deterministic UDF accessing at least one database table; and a deterministic user-defined function processing mechanism residing in the memory and executed by the at least one processor, the deterministic user-defined function processing mechanism collecting historical access patterns that indicate how the deterministic UDF accesses the at least one database table, and allocating a plurality of hash tables to the deterministic UDF based on the historical access patterns.