Calling most of the Teradata library functions in an external stored procedure that uses CLIv2 involves several expensive context switches because the external stored procedure uses a different interface mode to execute most of the Teradata library functions.
Additionally, some of the Teradata library functions require that the external stored procedure wait for any outstanding CLIv2 requests to complete before calling them.
The exceptions are FNC_malloc and FNC_free, which do not incur any additional overhead.
The best practice for an external stored procedure that use CLIv2 to execute SQL is to use Teradata library functions judiciously.
For details on which library functions must wait for outstanding CLIv2 requests to complete before they are called, see C Library Functions.