I'm far from an expert but seeing as no one has replied yet I will give you the benefit of my lack of knowledge:
The cartridge uses the barrel to burn power and accelerate the bullet however if you were to make the barrel, just to be extreme, 40 feet long then the powder would all be burnt in the first few feet and pressure would be falling after that so the friction from the barrel would be slowing the bullet down. It probably wouldn't exit the muzzle. On the other hand if you made the barrel only 3 inches long, in a 30-06, then all the powder would not be burnt and so the bullet would be moving quite slowly when it exits the barrel, the noise and blast is likely to be most impressive. So, there can be problems with both too long and too short.
From what I've read and been told with normal rifle length barrels and normal powders then you might lose in the region of 50 feet per second in velocity for each inch you chop off the barrel. However, as you can see from the extreme examples above, this seems to vary quite a lot depending on the length you start off with and the load you are using.