CE-297 sql query optimization