Need to do spatial query when using Export Map operation

Discussion created by wangzhifang-esrichina-com-cn-esridist on Apr 24, 2013
Latest reply on Apr 24, 2013 by wangzhifang-esrichina-com-cn-esridist
Hello everyone,
I have a need to do spatial query and attributed query when using export map operation on a map service resource. However, there is only "layerDefs" parameter on export operation.
While my map service only contains a point layer, so now I have a workround that do a spatial query(including where clause) on the point layer resource using query operation and fetch only lots of objectIDs, then push these result IDs to layerDefs of export, such as
"layerDefs=0:objectids in (1,2,3...9999,10000,....15000,....)".
This works but, as you see, the spatial query result may have more than 10 thousands IDs, and do such query only in database would be time consumed...
So I wonder is there any other ways to do my job? Or why not export map operation add a "geometry" parameter as query operation do?

Many thanks!