Well, it always depends. In a let's call it "dynamic scenario", a handgun is the best because it's portable and concealable. So you can bug out more easily than if you were carrying something bigger.
If you find yourself actually having to shoot indoors or at close range, it's serviceable but a shotgun is always better. In the open field and mid or long range, then definitely a handgun is not great to shoot at bad guys and, again, the advantage it offers is getting the hell away more easily.