Barrel length has nothing to do with accuracy, so scratch that from the discussion.
As for length, the longest barrels for .223 I've seen are 24", but I am sure 26" is doable.
Here's the problem. It all depends on bullet weight/style and powder type/charge. For a long barrel, you'd want a slow burning powder. Shorter barrels need faster burning powders to get the bullet up to speed. You'd want as much of that powder charge to be converted into gas pressure before the bullet exists the barrel. When you see a big flash, that is essentially the unused powder/pressure burning outside of the barrel where it can no longer generate pressure, and thus, no more velocity.
Here's an example. If you shoot a .22mag out of a 20" or greater barrel, there is no flash. But if you shoot a 22mag out of a 2" snubnose revolver, there is a fireball. The difference in velocity will be nearly 800fps. In short barreled handguns, the 9mm is much more efficient than the 357magnum. The 357 makes a nasty fireball and the end result is barely anymore FPS than a comparable 9mm.
I don't know what the max barrel is. I'm sure you could probably find a bullet and slow burning powder to fully utilize a 28" barrel...who knows. Just a guess. A .223 load optimized for a 20" barrel (like 2230c) is going to be less efficient than a powder like 2520 used in a 24-26" barrel. Likewise, a faster powder is going to be wasteful in a long barrel. If you make a load with a fast powder for a short barreled rifle, you might not see a gain at all in a 24" barrel because whatever powder was in that charge was converted into pressure before say 16" of barrel...(just an example) the bullet is then traveling through rifling, incuring uneccessary friction without any more significant push on it.
.22LR is said to reach max velocity at around 16" of barrel (not talking about hypervelocity or high velocity)...many of the match loads are just under subsonic. Many longer barrels were thought to have been more accurate because of length, but was really happneing is, these 26" barrels were keeping the bullet subsonic...making them more accurate (since not having to break the sound barrier).