I was using Toad’s SQL optimizer and it came up with the following addition to my join statements..
instead of say
emp.emplid = dept.emplid
it suggested
emp.emplid = dept.emplid + 0
What does the ‘+ 0’ do? I’ve searched for the past hour online and I cannot find anything. I know the (+) meaning, but I’ve never seen anything like this.
The
+ 0does what it looks like. It adds 0 todept.emplid. But from a performance point of view this does make a difference. By turning that into an expression Oracle is not able to use any index ondept.emplid.So if Oracle is choosing an index on
dept.emplidbut you would rather it used a different index/plan, then adding+ 0is a way to influence the optimiser, as there is not longer a match on that particular column. Any expression would have done the trick.The other way to go about this would be to get into optimiser hints. Although this can be a bit of a pain for big queries.