optimize code for oracle database