Where Optimizations Come From

I used to have this thought that optimizations in compilers and databases were a bit of a bandaid to badly-written code or something. I think this is not a correct mental model, though. I've also been trying to learn more about compilers recently, just because I have query planning problems that I feel like must have already been solved by the compiler world. So here's some musing. Languages like…