I didn't say longer barrels didn't yield higher velocities, they typically do, to a point. Longer barrels allow the expanding gases to work against the bullet for a longer period of time. The greater volume of expanding gases, as occurs in magnum revolver cartridges, is why they gain 300-700fps in barrels up to 20" but pistol cartridges like the 9mm, don't gain much. It's a limitation of the cartridge. I said the same powders that yield the highest velocities in short barrels, also do so in longer barrels.
Maximum velocity is not always the end goal. Manufacturers often use low flash powders to reduce muzzle flash in handguns used for self defense. Most so-called "short barrel" loads use low flash powders and bullets that expand at lower velocities but people assume they use a faster powder for higher velocity in short barrels. It's not true and doesn't work that way anyway.
An extreme example would be Buffalo Bore's 340gr .44Mag load. Buffalo Bore uses a non-cannister grade of H110/296. This load yields well over 1400fps out of a 6-7½" barrel but also over 1200fps out of the 2¾" Ruger Alaskan. A faster powder wouldn't get anywhere near that.