AnsweredAssumed Answered

Prevent extent calculation when adding query layer to map

Question asked by ffushoel on Jul 18, 2016
Latest reply on Jun 21, 2017 by ffushoel



when adding a query layer to ArcMap by ArcObjects code the extent of the newly created layer will be calculated based on data by default. This causes significant performance issues (i.e. full table scans with several millions rows).

When redefining a query layer in ArcMap manually an options-dialog is provided where you can choose between "Input Extent" and "Use Spatial Reference Extent" (see

The second option is what I need. Is there any ArcObjects interface to force this? Is there any way to prevent the extent calculation and to use a given Extent?


I've tried without effect to deal with: 

- Setting ILayer2.AreaOfInterest before loading layer

- Setting SpatialDomain in IFeatureClass.SpatialReference of the query class

- Loading a layerfile is no option in my case (the extent will be saved in layerfile)


Thank you.


Sample code:


    Protected Sub AddNewQueryLayerToFocusMap(ByVal sqlWorkspace As ISqlWorkspace, _

                                             ByVal featureClassName As String, _

                                             ByVal geomType As esriGeometryType, _

                                             ByVal spatialRef As ISpatialReference,

                                             ByVal map As IMap)


        Dim query = String.Format("SELECT * FROM {0}", featureClassName)

        Dim queryDesc = sqlWorkspace.GetQueryDescription(query)

        queryDesc.OIDFields = "OBJECTID"

        queryDesc.GeometryType = geomType

        queryDesc.SpatialReference = spatialRef


        ' Ensure that the specified name for the Query Layer feature class is not 

        ' already being used. 

        Dim newName = String.Empty

        sqlWorkspace.CheckDatasetName(featureClassName, queryDesc, newName)


        Dim queryClass = sqlWorkspace.OpenQueryClass(newName, queryDesc)

        Dim featureClass = TryCast(queryClass, IFeatureClass)


        Dim featureLayer = New FeatureLayerClass() With {.FeatureClass = featureClass}

        map.AddLayer(featureLayer) '==> extent calculation will be performed


    End Sub