Hear we go again!!!

BIRD SHOT IS CALLED BIRD SHOT FOR A REASON!!! DO NOT use bird shot to
TRY TO STOP AN ATTACKER, period! There are to many variables in these dynamic situations to risk your life. and lives of your loved ones, on BIRD SHOT!

To answer your question, nothing smaller than BB shot, more bigger than #4 buck in the 'apartment' or a trailer park. REAL LIFE shootings have proven this MANY times!

When considering shot gun ballistics you MUST look at the INDIVIDUAL pellets ballistic characteristics, primary depth of penetration in MANY different situations, when deciding what 'shot' to use.
Depends on what your objective is. For example, what is taught in law enforcement schools/hostage training is you take the shot you have when you have it, provided there is a good hit probability and there is limited risk to the hostage. Think about that, anytime you escalate there is the likelihood that the bad guy will kill the hostage on purpose, or he may fall while dying and his gun may go off since his hand is already on the trigger and it may kill the hostage, so what to do?
The typical home defense scenario is a bad guy comes into your home at night. If he is armed it is probably a handgun. So, you have a guy in your hallway who knows somebody is home and he comes in with gun in hand. How much time does it take him to fire when he sees you? The answer is somewhere around 1/2 second. The only way you can insure a hit before he starts his mechanical movement to fire, is to shoot him before he sees you. That throws him off, lots of noise, a sudden flash and something hitting him in the chest and maybe a couple more hitting him in the chest before his legs fail him. And how long before he loses the ability to get off one shot that hits you in the brain, or in the knee crippling your for life, or a poor shot that just castrates you? My point is the plan is to stop the threat without getting shot.
I once shot a fox and other time shot a jack rabbit with bird shot both at about 10 feet. Devastating, shredded them. At 10-15 feet the bird shot pattern is not much. Gun Digest did an article (see below) and found 7.5 shot spread from 2.5 to 10.5 inches at 5-20 feet. What that means to me is that if you come into my home with a gun in hand and I can aim my 12 at your hand and fire before your gun goes off, then your hand is shredded and it is unlikely you are going to do anything but drop the gun and cry out in pain. Could I do that? Probably because I was trained to shoot quickly at a person holding a hostage, but the same quick aim and fire is really no different than shooting a quick rabbit running in a thicket. Hunters who do the sporting clay course with rabbits can do it easily. Remember, you have a shotgun, 18 inch tube or so, and you only need to put that front bead on to a target the size of a hand with a handgun in it at 20 feet or less, easier than you think. So, while it may sound goofy to shoot the gun out of the hand, that is not the deal, the goal is to shred the hand. Do I teach that in CCW classes? Of course not. The question is what would I do, and to me it just a matter of planning. I am not afraid of the guy, I am afraid of the gun.
When I train new shooters, I give them a dowel rod and make them promise to take it home and walk through their house with it in the gun as if searching for a prowler. The eyes stay aware of the front of the gun/dowel at all times. Then I have them practice pointing the gun/dowel at various doors, hiding places, etc in their home as they move. It becomes pretty easy to point and fire at a small object in your home, like a gun in the hand. Myself, I am confident with a procedure like that. The next guys might want 30 rounds in an AR for the same purpose or the excellent 1911 with laser and light. I have all 3 at the handy. Different strokes for different folks.
https://gundigest.com/gun-reviews/s...ome-defense-too-much-too-little-or-just-right