Optimized DbApi.factory