It's hard to make suggestions without knowing more about exactly how the functions are used in queries, what the types matching the STRUCTs look like and how the instances of these types returned by the functions are used.
Passing STRUCT or ARRAYs requires crossing the boundaries bw Java and C, which is expensive with Java in the database.
I the if the type is some kind of aggregation of scalar types and the queries can be rewritten in terms of functions that return these scalar values individually things might be better.
Thanks for the response - you are correct that the STRUCT contained an aggregate type - basically an object with seven fields.
This was very convenient because the function could be used in sql eg:
a.id in (some condition)
I've done what you suggest creating arrays of primitive types but haven't really done any benchmarking yet.