There are many factors involved in working this out, which is why many people would say this is opinion based, and others say
What's "optimal" is whatever works for you. – Daniel R Hicks Sep 21 at 1:43
The main factors are
- your strength
- your weight
- your muscular endurance
- your aerobic capacity
- how fast you are trying to go
- what gear you're using
- how steep is the hill
- how long is the hill
With so many factors Daniel's comment is not surprising, and is actually pretty accurate.
Looking at various online sources, in general the cadence to aim for is at least 70 rpm. This probably higher than you're using; many of us climb at 50 to 60 rpm, which is hard on the knees.
To follow this advice you need to measure your cadence. You'll need a bike computer with a cadence sensor. Then climb the same hill multiple times in different gears, keeping track of your cadence and the time taken. Do the experiment at least twice to reduce the effect of random variations and the effect on your performance of training. An app such as Strava can do some of the record keeping for you.
Next make a plot of the times. Such a plot can show surprising things, but it will give you some knowledge about yourself. It may answer your question about gearing. If, for example, your times keep getting better as you go to lower gears, then you could benefit from having gears that are even lower.
The next experiment is to ride hills that have different gradients, in the same gear for all of the hills. Keep track of the time and cadence again, and make another graph. It may seem that this will give the same results as the first experiment, but in practice it does not; it gives you more information. An important point here is to include hills with a lower gradient (even as low as 3.5 to 4%), they give you a greater range of gears you can use, and are good for training on.
What to do with this information?
If your cadence is below 70, work to improve it. You can do this by riding less steep hills, faster. Also look into interval training to improve your strength. These approaches can avoid spending money on components that will only give benefit in the short term.
If your times keep getting better in lower gears, then spend the money on getting a cluster with bigger gears at the low end. Make sure your derailleur can handle the extra range before you do this. If it can't handle the range then you'll have to decide whether the extra cost is worth it to you.
If you look back at the variables listed at the top of this post, you'll see that every one of them can be changed. You can choose a different hill, with a different gradient. You can build up your strength, reduce your weight, build up endurance and aerobic capacity, choose a different pace, and choose a different gear.
By keeping track of your performance, you'll get feedback on how you're going. How it feels is not generally a good indicator of performance; I only ride by feel these days: sometimes I think wow, I destroyed that hill only to check the time and find I was way off my PB. Other times I've thought Uff, that was a struggle and found that I was minutes inside my PB.
In general, we get better power, and hence speed up the hill, with a higher cadence. But this is not true for everyone, as at least one of the linked articles will show.
As you develop, you will need to use different approaches to get improvements. Professional coaches frequently seek to introduce novelty into the training they give their athletes, so that the athlete has a new challenge, or training stress. It's when your training provides a new stress that your body responds with new growth. So when your improvement plot reaches a plateau, make a change. Instead of cadence, work on strength, or a different gradient, or shorter climbs.
Happy climbing.
Ps. I left out one important way of getting stronger and faster: ride with someone who's a bit faster, or chase someone who started a little before you. A little competition does wonders :-)