You generate a daily report according to the following query:
The Sales.ufn.GetLastOrderDate user-defined function (UDF) is defined as follows:
You need to improve the performance of the query.
What should you do?
We use a Common Table Expression (TBE) to optimize the query with a predicate pushdown.
Predicate pushdown is an optimization that applies conditions (predicates) as early as possible --- ideally preventing any loading of unneeded rows.
References:
https://modern-sql.com/feature/with/performance
Currently there are no comments in this discussion, be the first to comment!