Plan changes depending on the literal value in the sql
I am encountering a strange issue, during the execution of a sql. The sql's plan changes simply because of a literal value in the sql. Here are the conditions/changes which is impacting the sql execution plan.
(int.user_je_source_name,group_id) in (('XXX XXXX', 123702)) -- chooses right plan
(int.user_je_source_name,group_id) in (('XXX XXXX', 17122010123702)) -- chooses a wrong plan the only difference is the value for group_id.
We verified and confirmed that it is not because of the number of rows for that value in the table, the sql works fine if we trim down the number of digits to 7 digits, if it crosses 7 digits it chooses wrong plan.