Another note I've learned on higher octane gas: in areas prone to freezing temperatures (I live in the northern Midwest), 87 octane will, during winter, have ethanol added into the mix as an anti-freeze. This is commonly called the "winter blend", and is federally regulated to only be on the market during certain times. The ethanol has lower energy density than gasoline, and can hurt your mileage. Higher octane gas does not have extra ethanol added in. So there's a benefit to using midgrade or premium in cold weather.
Compression is fixed by the engine design. The only thing the ECU can do as a result of knock sensor input is retard ignition and close the throttle (and, on a turbocharged engine, lower charge pressure).
Retarded ignition does result in lowered gas mileage, but throttling down does not. It just decreases your maximum available power.
Plus, if you notice the decrease in power, your driving is not suitable for comparing gas mileage... ;-)
The maximum possible compression is, yes, since it is determined by the size of the cylinders and the piston stroke.
But retarding the timing amounts to reducing the effective compression--basically you are wasting some of the compression that's available by delaying the spark until the cylinder has started expanding again. I should have made it clear that it was effective compression that I was talking about.