Ammo manufacturers know that personal defense rounds aren't being shot out of 5" barrels. Their bullets are designed to function within a velocity range that includes 3" subcompact barrels.
Don't worry about barrel length. Buy something reliable, that you can shoot well, and that you will carry, in that order.
As a math problem for fun, to get MAXIMUM velocity, my guess would be somewhere between 15 and 20 inches. Pistol caliber carbines exhibit higher velocities than handguns. However, after a certain point, the drag created by the bullet traveling through the rifling starts to slow it down.