Two different plans in TEST & Prod
we have a problem in production database where we find some sql statements running very slow.
but if you run same SQL statement in TEST it runs < 2 secs.
Production DB Prod.SchemaA is exported into TEST DB as Test.SchemaA
When study the explain plan, we find Prod explain plan is different than test. if you create sql profile, by copying TEST explain plan, it would run faster in Production.
Now our question is why optimizer goes through two different plans when the schema structure same and data almost same in two databases?
Note that, we have two almost identical schema's in Production. Prod.SchemaA and Prod.SchemaB has same object names but some Prod.SchemaB may have small difference in indexes/constraints.