The magic: From the refinery, gasoline and diesel fuels are transported to terminals.
It is at these terminals that detergents and additives, are added, to formulate to produce high quality blends.
I tested my mileage with the various octane's when I 1st purchased my ES350. The better the octane - the better the gas mileage.
One thing I really noticed was the performance. What a difference between 93 octane vs 88 octane. (and the price difference)