Couple of misunderstandings in your post.
A knock sensor does not help against pre-ignition. Luckily what you will have in your scenario (high compression engine with low octane fuel) is not pre-ignition, as that will destroy an engine in seconds.
In your scenario you will have “spark-knock”, aka “pinging”. It occurs after the spark plug ignites the fuel. The pressure in the chamber raises rapidly and the fuel/air mix in a different part of the chamber spontaneously ignites causing a second flame front.
The two flame fronts colliding causes a super sonic shock wave that rings the engine block making the characteristic pinging noise.
Spark knock is not terrible for an engine although can cause damage if it is going on for a long time.
The ringing of the block tends to be in a fairly narrow frequency range, right above 6KHz. The knock sensor is nothing but a piezo-electric microphone coupled with a bandpass filter that removes everything but the 6KHz tone.
When the car’s computer gets a signal from the knock sensor it retards the timing (making it happen later). The later spark decreases the peak chamber pressure as more of the combustion event happens after the piston has reached top-dead-center, and has started going down again (effectively making the chamber “larger”).
Since the peak pressure is lower, the lower octane fuel does not self-ignite anymore and the pinging stops.
But since the ignition timing is later, more of the combustion energy is wasted on the down stroke and power output and fuel economy suffers.