Not sure if I understand what indexed view is doing behind the scenes, in SqlServer

I am using SQL Server 2008 and started looking with Indexed Views helping me speed up some of my queries ... since my schema is not basic.

So, if I have a table, the following ...

**ParentTable
ParentId INT PK IDENTITY
Name VARCHAR(MAX)

**ChildTable
ChildId INT PK IDENTITY
ParentId INT (FK to the table above)
Name VARCHAR(MAX)
Boundary GEOGRAPHY
CentrePoint GEOGRAPHY
CentrePointFlattened GEOMETRY

      

So, for each row in the parent table, it can have 0 to many children.

First, if I create an index'd view for the children, it doesn't work if the registered ParentId can be null. So I need to do this.

Now the question.

I have an index view of the children table inner join'd into the parent table (note that I am only indexing some of the fields from any table) ...

(pseduo sql code)
ParentId INT
Name VARCHAR(MAX) AS ParentName
ChildId INT
Name VARCHAR(MAX) as ChildName
Boundary GEOGRAPHY

      

Now, is the data for these 5 fields serialized / copied to another location again? or does an index scan only create some index id which is the data for the table?

+2


source to share


1 answer


Yes. An indexed view is basically another invisible table that automatically updates as the underlying tables change.



+2


source







All Articles