I assume you are using POJOs in order to be able to use methods like ResultQuery#fetchInto(Class) and Record#into(Class), which behind the scenes rely on jOOQ's RecordMapper.
jOOQ's default
DefaultRecordMapper implementation cannot fully support primitive types in a generic way, as there would be no way to distinguish
null values from the primitive type's default value (e.g.
0L for
long). There was a recent related discussion which may also help to understand the problem:
https://github.com/jOOQ/jOOQ/issues/9704#issuecomment-570514225.
Please also note that a generic RecordMapper implementation would be expected to use reflection to call setter methods, and when Method#invoke(Object, Object...) gets called you would already there have some autoboxing. So a custom RecordMapper implementation would also not fully alleviate this issue.
To optimize for performance I think you will in a first step want to optimize the SQL query and in a second step also review your JDBC parameters, which for many databases can have a big impact performance. But I assume you have already done that.
To further maximize performance for a given query you may want to go down to the JDBC level and do the POJO mapping for the query manually, which you can achieve by using ResultQuery#fetchResultSet() which returns a plain JDBC ResultSet. With performance testing you will then be able to establish how much this improves things.
Hope this helps,
Knut