Buy the best firearm you can afford. Do not buy something cheap, though. Life's too valuable to bet on a cheap firearm, particularly a cheap auto.
I've gotten rid of pistols that I personally loved, but couldn't trust to be there for me 100% of the time. Come to think of it, its a lot like members of the opposite sex. Some are lovely to look at, lots of fun, but you can't be sure they'll be there when the going gets tough. There's nothing more dangerous than an unwarranted feeling of security.
I'm not a demagogue, I have several types and makes of sidearms, but I won't have two things in my house- an inaccurate weapon, and one that does not go 'bang' EVERY time I pull the trigger, unless I can attribute it to an error I made.
Stick with the 'higher end' manufacturers (OK, you can start flaming me now, but I'll remain firm). If you get a cheap sidearm, get one thats as heavy as possible, so you can still use it as a club when it jams / mis feeds / misfires. Plan on $500.
Secondhand can be an excellent choice, but take someone knowledgeable to help fully realize its condition. Some are Princesses that have not been fired much, but may have holster wear. Some gleam like jewels on the outside, but have had two lifetimes of rounds down the tube.
Some ranges have a selection of weapons you may try for a small fee; an excellent way to get a feel for different calibers / models / manufacturers.
All the ins and outs of selecting a used firearm could fill a number of books, but represent a significant savings over new. Some shops will let you fire a prospective used weapon, some won't. Make sure they have a warranty (at least 30 days), buy / beg / borrow as many different types of ammo in that caliber, and shoot, shoot, shoot in that warranty period.
Me personally, no warranty, no sale. Test firing is a plus, but not a deal breaker for me.
When you find a ammo that works (and weapons have preferences) practice with it and carry it. Also buy a good quantity of the worst stuff, preferably the one that jams / mis feeds / misfires. Why? Its also excellent for practice, so when a jam happens, clearing it will be instinct.
Personally, I won't carry anything less that a 40 cal, but if you can't physically handle the recoil, work with it anyway. What seems excessive to begin with becomes less intimidating with practice.
Make sure whatever you decide on that it fits your hand comfortably. Steel Magnolia doesn't like my Glock 27 or the Beretta 96, but handles a full size 45 1911 like a pro. It fits her hand better because of the magazine design (single stack vs double stack).
But, the most important thing is, 'the little pistol you carry is better than the big one you left home....'
Best of luck!