Forum Discussion

blackbaron's avatar
blackbaron
Copper Contributor
Feb 14, 2022

How does views in database improve it's performance. Is quering between views create good performan

Hi,

 

I'm working on an application where I have the following doubt:

1. Does a view improve the performance of DB ?(Was unable to understand  even after reading the below reference)

2. In case I create 2 views and run a join query between them, will it affect the performance of the DB ?

3. I'm using Azure SQL DB for this project

 

Reference : 

https://docs.microsoft.com/en-us/sql/relational-databases/views/views?view=sql-server-ver15

https://docs.microsoft.com/en-us/sql/relational-databases/views/create-indexed-views?view=sql-server-ver15 

https://docs.microsoft.com/en-us/sql/relational-databases/views/create-views?view=sql-server-ver15 

 

 

Any help on this is greatly appreciated!!

 

 

Regads,

black baron

 

PS: If this post has helped you, please vote for it.

  • olafhelper's avatar
    olafhelper
    Bronze Contributor

    blackbaron , a view is just a predefined query (like a macro) and has no effect on performance.

    You can create an index on a view, but there are several limitations.

    Better create index on the base table instead on a view; so that ad-hoc queries can also benefit of the index.

    • blackbaron's avatar
      blackbaron
      Copper Contributor
      Thanks olafhelper ๐Ÿ™‚
      This answer gave me a direction. Hoping to see some other viewpoints too

Resources