1. An apparatus comprising: at least one processor; a memory coupled to the at least one processor; a first instruction stream residing in the memory; and a code optimization mechanism residing in the memory and executed by the at least one processor, the code optimization mechanism reading an instruction in the first instruction stream that references a database having metadata, accessing the metadata of the database, and optimizing the first instruction stream to generate therefrom a second instruction stream according to the metadata of the database referenced in the first instruction stream.