Glock 17: 3,000-round, no-clean-torture-test produced 0 failures
I bought it new, cleaned the barrel and added lube (M-Pro 7). I added additional M-Pro 7 every 100 to 150ish rounds, but NEVER cleaned. I fired 3,000 rounds over 5ish months, and never experienced any failures of any sort. Will it fail some day? I am sure it will, and for that very reason I do carry a backup.
My most important consideration for your question and case is, are you experienced with pistols? If no, SKIP THE .40 S&W, go with the 9MM! If you are experienced, either is great.
Regarding noise, it is a mixture, physically, of pressure finally escaping the muzzle, and the bullet "cracking" through the sound barrier. (So it is explained on a video that I purchased). The 9MM and the .40 S&W are very similar in both pressure and velocity, and as such SHOULD produce similar degree of noise. Personally, I always try to wear form inserts in the ear canals AND headphones, which gives me OVER 70 d of noise-reduction. In many cases I can barely even hear people shooting.
As stated already, compensated models (G17C & G22C) are louder than the non-compensated models G17 & G22)! They also produce a marked flash of light in darkness which is not good if this will be your CCW piece. Lots of considerations. Good luck and let us know what you decide. In closing, there a hundreds of indoor, professional ranges that lease pistols by the hour, to fire inside their range (obviously you can't leave with it and return it later). Go try each one out.
Doc2005