External routine library management and performance

External routine library management can affect the routine performance since the database manager dynamically caches external routine libraries to improve the routine performance.

For optimal external routine performance consider the following:

  • Keep the number of routines in each library as small as possible. It is better to have numerous small external routine libraries than a few large ones.
  • Group together within source code the routine functions of routines that are commonly invoked together. When the code is compiled into an external routine library the entry points of commonly invoked routines will be closer together which allows the database manager to provide better caching support. The improved caching support is due to the efficiency that can be gained by loading a single external routine library once and then invoking multiple external routine functions within that library.

    For external routines implemented in the C or C++ programming language, the cost of loading a library is paid only once for libraries that are consistently in use by C routines. After a routine is invoked once, all subsequent invocations from the same thread in the process, do not need to reload the routine's library.