AnsweredAssumed Answered

ArcGIS Server Feature Service vs Map Service to query large number of records using JavaScript API

Question asked by jesposo on Jun 13, 2017
Latest reply on Aug 23, 2017 by jtessier

We are weighing the relative impact of serving a large data set in ArcGIS server as a map service with a very large MaxRecordCount or as a feature service with a smaller MaxRecordCount.  There is no need to edit the data via the feature service - the service is meant to be for display and query purposes, not editing.


My question is - which is the better solution - a max record count of 400K on a map service or creating a feature service for the layer?


We have a statewide parcel layer with about 400K records that is hosted as a map service in Esri Managed Cloud Services with a MaxRecordCount of 5000.  A consultant is developing a custom app using the JavaScript API in which there is a need to query the entire dataset.  When MaxRecordCount is 5000, any query (using QueryTask) against a layer (e.g., parcels) in that service will only return the first 5000 rows  – for example, if the application sends a query for all parcels greater than 1000 acres, and we then want to further filter the results (e.g., those parcels having zoning of “Urban”), the second query/filter will only be applied to the first 5000 records returned – even if there are more parcels meeting the criteria - so the results will be incomplete.  When we increase the MaxRecordCount to a number larger than the total number of state wide parcels (~377K), like 400K, the queries will return the complete set of features the meet the criteria. However, we don't really want to increase the MaxRecordCount to 400K.


Esri suggested the solution below, which requires a feature service rather than a map service:


If the server supports pagination, the FeatureSet returned as a result of executing the query task contains exceededTransferLimit boolean. When that boolean is true, it indicates there are more features that matched your query than what was returned. Now, you can use Query.start and Query.num parameters to fetch those additional features that satisfied your query. Repeat the same query with new values for “start” and “num” parameters until FeatureSet.exceededTransferLimit becomes false – at which point you would have fetched all features that satisfied your query.


Your sequence would like this:


Query 1:


start = 0; num = <MaxRecordCount>

returns FeatureSet.exceededTransferLimit = true


start = 1 * <MaxRecordCount>; num = <MaxRecordCount>

returns FeatureSet.exceededTransferLimit = true


start = 2 * <MaxRecordCount>; num = <MaxRecordCount>

returns FeatureSet.exceededTransferLimit = true


…and so on until exceededTransferLimit becomes false.



Would appreciate any guidance or insights...