AnsweredAssumed Answered

SetDefinitionQuery Efficiency Issue

Question asked by mattkajewski on Nov 9, 2018

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);

Outcomes