My query's unpivot
query performance is very low, it runs very slowly and takes around 11s to execute, while the base
query that it's based on takes around 60ms to execute.
The base
query is complex, with several joins, but it returns only a few rows.
Unpivot operates on ~7 group-by columns and unpivots around 40 columns.
Explain query plan shows no details, only that the cost of unpivot is very high.