Hi,
I have a question about the spatial index in a view.
I’m using a MsSql2008FeatureLayer layer
MsSql2008FeatureLayer msSql = new MsSql2008FeatureLayer();
msSql.TableName = MyView
In “MyView”, the select returns a geometry data from a table (I’ll call “MyTable”)
I wanted to create à spatial index for “MyView” but I couldn’t, because my view has “left outer join” so I couldn’t create a primary key, so with no primary key I can’t create a spatial index.
Is my view uses the spatial index to “MyTable” (which one has the geometry column and a spatial index) ?
Or to use a spatial index on a view, I have to create a spatial index in this view?
I tried to look for information in the execution plan of my view but I did not see any call to the spatial index;-(
But with a table with a spatial index, I have sometimes the same result that is no call to the spatial index (while the table has a spatial index)
Thanks a lot for your help.
Regards.
Stéph.
View and spatial index
Hi Steph,
You are right that if there is any relationships in the view, then the spatial index can’t be created.
We did some investigations on the spatial index and found out the spatial index which created in the table also can be used but with some conditions. To optimize the performance, SQL Server allows to use the spatial index from the table which is also included in view when the table records are at the specified number(we can see the level when setting the spatial index).
So, it makes sense why the spatial index is called sometimes.
If anything wrong with my investigations, please feel free to correct me.
Thanks,
Johnny
Hi Jonnhy,
Thanks for your help.
Regards.
Stéph.
Steph,
You are welcome.
Regards,
Johnny