qry with no binds is re-parsed on 2nd run and CBO chooses a much worse plan
Hi,
This is actually an E-Business environment and the SQL code is being run through a bespoke Concurrent Request, but I don't se that being relevant, it's still SQL after all. Database is 11.2.0.1.
The problem is, when this SQL is run for the first time, it gets hard-parsed, and runs with a reasonable execution plan. If the same SQL is run again, pretty much straight away, so the SQL_ID is still cached in the library, it is getting hard parsed a second time, and for some reason the CBO is choosing a terrible plan full of FTS's. A third run of the qry will soft-parse and re-use the bad plan. The CBO cost of the two plans is wildly different. The good one is 171285, and the bad one is 297919503.