Define search order (spatial, definition expression) on map service for exportMap?

Discussion created by ElcaProjVugis on Jul 25, 2013
We???re developing a web application based on ESRI ArcGIS Server 10.1 and the latest ESRI JavaScript API. In our SDE (Oracle) database we have a featureclass with over 1???000???000 million points loaded. This feature class is deployed as a map service (through ArcGIS Server with MapServer) without any scale limitations (min scale, max scale) in the map service itself. That means that the points (1???000???000) would be visible at all scales. The scale limitation is then done through the client (Javascript). It displays those points only below a scale of 1:50???000. But for a certain use case the scale limit is deleted, therefore the points will again show in all scales. But the use case also included, that only a few points should be shown. This is done through the definition expression set on the layer, that is loaded in the client. The layer then shows only, let???s say 50 points. The problem now is, if we zoom out to a big extent (1:1???500???000 ??? complete Switzerland), the server somehow crashes and cannot deliver the map image to the client for this layer. The problem seems to be, that the server first tries to load all features in the extent, that means 1???000???000 and then tries to filter them with the set definition expression. This leads to an instable behavior of the server, it does not respond anymore.

So the problem seems to be the ordering of how the server filters the features to get the map. He first does the spatial check and then filters it with the definition expression. This is the best and fastest solution if we have small extents (small scales), but for big exents (big scales) this does not fit. The question is, if there???s a way to tell the mapservice how he should do the filter ordering. Filter first and then spatial or vice versa. With arcobjects there would be a way to do it with the ISpatialFilter interface, there you can define the search order. But is there a way of how to do it with a map service?