I have both 9mm and .40 calibers in larger Glocks, but my only sub-compact Glock is a 9mm G26.
Good shot placement should be a high priority with any handgun, but it is especially critical with smaller/shorter guns that have less velocity for the bullet to work with, a short sight radius, and possibly other features that make them more difficult to shoot well. The tie-breaker here is ammo cost. You can buy 9mm ammo for 25 to 50 percent less than .40 ammo, and that translates to a lot more practice time for the same expenditure; more bang(s)-for-the-buck, you might say. The lighter recoil impulse and extra shot in the magazine are nice bonuses for the 9mm, but the less expensive practice costs are what will keep your shooting skills high and improve your survival possibilities in a bad situation -- IF you actually seize this advantage and make the most of it.
"Placement is power" -- seen in an article by Stephen A. Camp
(RIP, Mr. Camp; you will be remembered, and missed)