I have always said:
Memorizing for the low levels
Learning for the high levels
Forgetting for the geniuses
Obviously in math, once you have done enough questions relating to that formula, then it will become second nature and you won't even need to think twice to recall the formula.
You should learn the really basic ones, since the others are just built upon the basic formulas. If you truly understand how a formula works, then you can easily derive it when you needed it, although it may cause some inconvenience.
Say, the trig identities for example. Some of them looks like God's Wrath...but you can derive them from basic ones if you know what you are doing.
Of course, if you take IB Mathematics Higher Level, your Data Booklet has everything you need for you :P