With a custom module providing a history provider, there's potential for certain optimizations; there might be functions available to insert batches of records, or defer index updates, or anything like that.
With a JDBC driver, you always have to convert and send your data with the "lowest common denominator" SQL, data-table-based, rows-and-columns-matching format.
So, currently, the main difference between the two would be in storage performance (in theory; specifics will depend on the custom module and who's authoring it).
Both will likely get roughly the same query performance advantage (e.g. of Timestream), because in that case, they both have to ultimately talk to the lowest common denominator of Ignition itself - we don't currently allow history providers to provide their own aggregation logic, and do it all inside of Ignition. That's something we're considering changing to make connections to tools like Timestream, TimescaleDB, etc, more valuable.