Performance problems with ExecuteRelationshipQueryAsync for Feature service

Discussion created by markus.hjarneesri-se-esridist Employee on Dec 21, 2010
Latest reply on Dec 24, 2010 by markus.hjarneesri-se-esridist

I originally posted this in the Silverlight/WPF API Forum, but there I was recommened to post it here instead.

When we tried using QueryTask.ExecuteRelationshipQueryAsync() to get related objects (from a list of source object ids) through a 1-1 relation in the map service, we saw that it was very slow and when including more than ten or something source object ids we got a timeout from the map service.

Tracing the database we saw that for each source object id the following SQL was excuted (TB_Adress.DBO.TBLeveransstopp being the related feature class):

declare @p1 int
set @p1=304
exec sp_prepare @p1 output,NULL,N'select OBJECTID, Shape from TB_Adress.DBO.TBLeveransstopp ',1
select @p1

And since TB_Adress.DBO.TBLeveransstopp contains over 568,000 rows this query took about 4 seconds.

When we tried to repeat this using the REST API directly in the browser (which we could), we noticed that we were using the FeatureServer endpoint. So then we tried the REST API using the MapServer endpoint, and then the performance was good (and we didn't see the SQL query above in the database trace).

So, is this performance difference between MapServer and FeatureServer when querying related records expected or is it a bug?

Our test environment is ArcGIS Workgroup Server 10.0 SP1 on SQL Sever 2008 Express R2.