SP optimization with TVF, View
Had problem with a SP,
- SP has a few parameters
- SP unions three queries and then filter by a parameter and then return data
- One of the three queries links a TVF with a few tables
- The TVF links a standard view with a few tables
- The View links several tables, however not all tables are used by the TVF
Symptom:
- One table used by the TVF has many scan count and slows down the SP
Optimization options:
- Bring the parameter to the three queries referenced by the SP - no effect
- Modify the TVF and pass in the SP parameter - Speed up 4x
- Replace the view with the base table and remove unused tables - Speed up 4x
Comments
Post a Comment