Query optimization is a function of many relational database management systems. The query optimizer attempts to determine the most efficient way to execute a given query by considering the possible query plans and complex type query struct which is using the store procedure and testing with in sql.