Well, barrel length doesn't do all that much for accuracy past a certain point... You need it to be long enough to impart spin and stabilize the bullet and a long time ago it did take a longer barrel to pull that off. But for a modern auto, any of the popular lengths should suffice. I've seen a guy shoot a .40 compact HK very accurately out to 200m, and I've shot pistols at ranges like that myself.
But I also have a G17 and a G17L, and though that 17L is a bit more tweaked than the 17 is, it is a whole lot more accurate. Just that bit longer sight radius really made a difference, and a longer barrel also gives you more velocity and that helps with ballistic variables. The faster and straighter you get the bullet to the target the easier it is to achieve accuracy. Just because the pistol technically can do it doesn't mean we always can, and all those little edges help.
As for 5" or 6"... Well, I just shot my first IDPA match and the 17L I used isn't "legal" to use. So in this case, the G34 5.25" bbl. or whatever would have been better. But I got the pistol a while back and really wanted this particular one and don't regret it, so it really comes down to that. If you plan on shooting matches now or in the future, make sure it is "legal". If you plan on carrying it, you may find either one to be too long. So I'd get the 6" if no IDPA and carry isn't a concern.
6" barreled autos give you an 8"+ sight radius and that extra bit of uumph which seems to be just about right with autos if you ask me. Any longer and they are just unwieldy.