depends. For just handling the shorter the better. For aiming the longer the better.
I had a gunsmith test velocity loss in a 3" 870, from 30" down to 22". Slow loss to 25" then dropped off faster, so he made my barrel 25".
Overall I'd guess 24-25" is best.