Php While Loop Sql Query Compiler Code Generation And Optimization