# eXtremeSQL Functions Preload

> For persistent databases, it can be a significant optimization in some cases to preload C++ User Defined Functions into memory from external dynamic load libraries. Specifically, the performance gain can be achieved when there are not too many UDF's in the database (all of which are used) and it is critical to not incur a timeout when the UDF is being used for the first time.

> Note that this feature is included specifically for applications that demand optimal performance like the Securities Technology Analysis Center (STAC) benchmark; and it is intended for use on Unix-Linux systems.

> ## C++ Applications

> In C++ applications the SqlOptimizerParamter class parameter `preloadUDF` can be set to true to enable the preload feature; then the optimizer parameters are added to the McoSqlOpenParameters passed the McoSqlEngine method `open()`. For example:

>         McoSqlEngine engine;
>         McoSqlOpenParameters params;
>         SqlOptimizerParameters oParams;
>         oParams.preloadUDF = true;
>         ...
>         params.optimizerParams = oParams;
>         engine.open(params);
>         ...

> ## xSQL Configuration Parameter

> When using xSQL as the SQL server application, the preload feature can be set as xSQL parameter in `sql_optimizer_params` section. When enabled, xSQL will load all UDFs on startup:

>         sql_optimizer_params : {
>             preload_udf : true
>         }