This query takes a long time to be executed (eg. 6 minutes) with this query plan, but the same query with another query plan takes only 6 seconds (with the same data cardinality)

Filippo 2016-07-22 09:11:47

This query is inside a Stored Procedure that use Synonyms (the tables SYP_) but the test has been done using the same real table.

If i run the same query interactively, it takes 6 seconds and the query plan is correct.

In attachment you can find the "slow" query plan, but if needed i can send the "fast" query plan for comparison.