Just wanted to share a small bug that we found the other day when doing some work with the ArcGIS Server Flex api (v2.0).
I am working on a proof on concept app where I need to return a very large number of points. Possibly 500,000+ points. I dont need to actually display them (the selected points), just capture some attributes of the points.
Its very cool that Esri has caught on to doing things this way, as I know I have been doing it for years, starting in the early days of ArcIMS. ArcIMS and to some (lesser) degree, ArcGIS Server, aren't very efficient with querying/parsing large result sets, and thats totally understandable. What we have always done is to just grab the absolute minimum of fields when we send a query - usually OBJECTID or other unique identifier. Then we take those results and send the full query using the objectid list. Yes, its another trip to the server, but it is almost always faster and far more flexible/powerful.
Anyway, so again, I needed to select a really large number of points spatially on the map. Obviously we can't think about displaying a huge number of points like that on the map, and luckily we dont need to in this case. But, in the case that you do, I would highly recommend you check out Mansour Raad's blog post on point clustering. Fantastic work.
So, it would seem that using a querytask and executeForIds (new in 2.0) would be my best bet. Instead of returning attributes of your selected features, this method simply returns an array of objectids that you can then use to do whatever you like. So, executing a query directly in the browser based REST services explorer with "Return IDs only" (the equivalent executeForIds in Flex) set to true, the operation works exactly as expected. However, if I use Flex, it doesnt work as I hoped. It takes forever, and will eventually fail. Looking at the query request using firebug, I noticed that the url doesn't include returnGeometry = false, even though I set it explicitly to false. Strange huh? So, yeah, its attempting to grab the geometry for all 600k points - and that's obviously causing quite a strain and eventually causes it to fail. Well, it turns out to be a bug, but luckily, there is a very easy workaround.
Simply hardcode a returnGeometry=false into your querytask url.
var queryTask:QueryTask = new QueryTask;
queryTask.url = 'http://server/ArcGIS/rest/services/servicename/MapServer/0?returnGeometry=false';
var query:Query = new Query();
query.spatialRelationship = spatialRel.selectedItem.data;
query.geometry = selectedGeom;
query.returnGeometry = false;
queryTask.executeForIds(query, new AsyncResponder(onResult, onFault));
I had no idea that type of workaround could work, it indeed it does.