Force_legacy_cardinality_estimation hint questions

All we need is an easy explanation of the problem, so here it is.

  1. Does the force_legacy_cardinality_estimation hint change cardinality for the whole query (or stored procedure) or just the section of code it’s applied to? (For example, if there are multiple SELECT statements in a Stored Procedure but the hint is only on one of the SELECT statements.)
  2. Can you use the hint in views?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

  1. The force_legacy_cardinality_estimation hint changes cardinality for a particular statement it is applied to, not for the whole batch or an object (SP, trigger, UDF and so on).

  2. No, you can’t, because the SELECT clauses in a view definition cannot include the OPTION clause.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply