Contents
Why is MY SQL Server view so slow?
(1) make sure your statistics are up to date on all the underlying tables. Almost every single operation is showing a massive gap between estimated and actual rows, which could help to explain suboptimal optimizer choices. (2) get rid of two lookups by adding the following columns to the following indexes (probably as INCLUDE columns):
I am a little suprised as I thought correlated subqueries perform worse than joins. Depending on how much data is in the tables, you may need to place indexes on the columns that are being joined against. Often slow querying speed comes down to lack of an index in the right place.
Why does the filtered version of SQL take so long?
The filtered SQL literally looks like: I am coming to you guys because I am lost as to why the filtered version could possibly take so long. It should be extremely simple for the SQL engine to find those 16 rows right from the start of the execution and then calculate / look-up the values for the 130 columns.
How to improve view performance with context filters?
You can set one or more context filters to improve performance. Create a dependent numerical or top N filter – You can set a context filter to include only the data of interest, and then set a numerical or a top N filter. For example, suppose you’re in charge of breakfast products for a large grocery chain.
Which is better a single context filter or many context filters?
Using a single context filter that significantly reduces the size of the data set is much better than applying many context filters. In fact, if a filter does not reduce the size of the data set by one-tenth or more, it is actually worse to add it to the context because of the performance cost of computing the context.
How to materialise SQL Server view in staging table?
You could ‘materialise’ this view by selecting it into a staging table on a regular basis (ever x minutes via a schedule) and selecting directly from that table in your app. I’d question how useful 150 columns is to an end user.