Methods, systems, and computer program products for accelerate database through runtime code generation are described. A system provides a library of transformation functions that each transform an original function in an intermediate representation into a transformed function in the intermediate representation. The system receives a query. The system obtains an original database function used to execute the query, the original database function being in the intermediate representation. The system generates a new function that is a query specialized version of the original database function. The system generates a result for the query, including executing the new function instead of the original database function.