SetDefinitionQuery Efficiency Issue

252
0
11-09-2018 01:14 PM
MatthewKajewski
New Contributor

I set the definition query on my feature layer to show what I want by year.  However sometimes I want to query past years, so i have a function that sets the Definition Query to include all years, then I query the feature layer, then set the definition query back.  I notice that in the beginning the SetDefinitionQuery works very fast, but the more times i use this function that SetDefinitionQuery sometimes takes up to 10 seconds or more.  What could be happening here?

string currentDefinitionQuery = GetLayerDefinitionQuery(layerName);
                BasicFeatureLayer searchLayer = FeatureServiceManagement.GetBasicFeaturLayer(layerName);
                if (searchLayer == null)
                {
                    return null;
                }

                searchLayer.SetDefinitionQuery(inDefinitionQuery);

                // define a spatial query filter
                var queryFilter = new QueryFilter
                {
                    WhereClause = inWhereClause,
                    SubFields = inSubFields
                };

                // apply the spatial filter to the feature layer in question
                RowCursor rowCursor = null;
                rowCursor = searchLayer.Search(queryFilter);

                searchLayer.SetDefinitionQuery(currentDefinitionQuery);
0 Kudos
0 Replies