"The higher compression rate the engine has, the higher octane number is needed" is definitely part of the story, the broader part of the story is that the more prone to detonation an engine is, the higher the octane of fuel you want to put in it. A relatively low performance, low compression engine with a poor combustion chamber design might well need higher octane fuel than a much higher performance engine with better chamber design and cooling.
In some engines higher octane fuel does give more power and in some engines it might just reduce the chance of it going boom!