Processing cursor is taking long time

Discussion created by gkar68 on Mar 9, 2013
Latest reply on Jun 6, 2016 by fpiona
I am maintaining a code on arcobjects 10.1, and there is a bug happening.
I have a code that is parsing through a cursor, and generate a where clause statement to run it on a second query.
So the code is like this

IFeatureCursor containsCursor = null;
IFeatureClass featureClass = null;
ISpatialFilter spatialFilter = new SpatialFilterClass();
IFeature tempFeature = null;

  featureClass = workspace.OpenFeatureClass("tablename");
  spatialFilter.Geometry = operationalUnit.Shape;
  spatialFilter.GeometryField = featureClass.ShapeFieldName;
  spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;

  containsCursor = featureClass.Search(spatialFilter, true);
  tempFeature = containsCursor.NextFeature();
  String whereClause = null;
  String fieldName = tempFeature.Table.OIDFieldName;
  while (tempFeature != null)
   if (tempFeature.HasOID)
    whereClause = whereClause + String.Format(" and {0} <> {1}", tempFeature.Table.OIDFieldName, tempFeature.OID);

   tempFeature = containsCursor.NextFeature();

  (do something with the where clause)

The loop that is generating the where clause is talking long time.
and when it is done, it tries to connect to the database, and the connection is dead.

Now, the funny thing is the slowness in only on the Dev server.
When I run it on my machine is fast.

This is my full details information

On my Dev server: It is a virtual machine, with Windows 2008R2
I run ArcGIS serer 10.1
I run the process binding to the Server, and to the server license.
I compile the process to run as 64 bit in order to bind to the server.

I access the database through Application Server SDE 9.3

P.S: I don't use direct connection (and we are not going to change the code to use it)

I measured the length of the statement, and on the server for 3500 records is taking > 45 seconds.

On my machine: my machine is Windows 7 with 8 gig Ram.
I run ArcGIS Desktop.
I compile the code to x86, and run binding to the desktop.

For the same amount of records it is taking < 4 seconds.

What is wrong there?