edited optimize.sql and added test sql query