Forum Discussion

kevinconseil's avatar
kevinconseil
Copper Contributor
May 29, 2020

How to increase SQL query performance of a view?

Hi everyone,

I am new to Microsoft community, so please let me know if this post is not in the right forum and if so which one would be the right one. 

 

issue:
- Update & query (using Power BI) of my Sales Weekly View takes forever (>30min) and I would like to understand how I could improve this

 

Current setup:
- Sales Daily View: View containing aggregation and joins of two main sales tables and a date table

- Sales Weekly View: View joining the "Sales Daily View", a sales table and two dimension tables and containing extensive logics (mainly aggregations)

 

Please let me know if you have any idea how to streamline this and improve the performance of the view.

4 Replies

  • kevinconseil 

     

    Hi Kevin

     

    I1)f you want to use a view (slow) then you can put indexes on the view on the columns which are used in the join clauses.

    3)You can also create indexes on the columns of the tables of the view, that are used in the join clauses

    4)Stores procedures are usually faster then views because they are compiled

     

    article:

    https://www.techrepublic.com/article/see-performance-gains-by-using-indexed-views-in-sql-server/

     

    Hope this helps,

    Bye

    • kevinconseil's avatar
      kevinconseil
      Copper Contributor

      Simple_Balayeur Thanks for the info 🙂

      1- By putting indexes on a view, do you mean creating a indexed view ? If yes then this is currently not an option as my view does not fit many requirements from the indexed view
      3- I already have indexes on the base tables of the view

      4- I m gonna investigate the stored procedure thanks 🙂

Resources