You want something you can engage with at close range without going completely, 'flash blind' or nearly deaf in the process. It, also, has to be short barreled in order to allow you to aim and fire quickly in any direction - regardless of how confined the space might be.
For many years I kept a long barreled S&W Model 41 with 3 magazines by my bed; but, in those days, we slept upstairs; and I would have probably engaged in the hallway or, at least, on the second floor of the house. May not sound like much of a pistol; but, I assure you the contents of one of those magazines flying down the hallway would give anyone pause; and, at in-house distances, I wouldn't have been missing.
Today, we live in a ranch-style home; and, I have to worry about things like being engaged by someone from outside the building. You know, like my neighbor who was recently shot 5 times through his dining room window at 1:30 in the morning! The cops told me I didn't have to worry, though. Apparently it was some sort of private, 'drug beef'. I guess I should be glad the shooter(s) got the right address, huh!
In this kind of situation your short barreled tactical rifle, and lots and lots of ammo stuffed into a high capacity magazine are ideal self-defense tools - especially if you're lucky enough to have a, 'can' on the end of the barrel. You should always keep a semi-automatic pistol within easy reach in order to, 'fight to the rifle' or shoot out any interior lights that might prevent you from moving.
It's a big advantage to preplan your points-of-engagement in order not to take out any of the neighbors along with the BG's. (I like stairways and hallways.) Having one or two Pit Bulls, also, doesn't hurt your chances of survival!