Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

Performance in Writing to an Oracle SDE Instance

$
0
0
Hello –
I’ve got a process that’s built in C# using ArcObjects v10.1 that reads data from a feature class in a source File Geodatabase, applies updates to attributes and sometimes the shape, and writes a new feature to a target feature class in another File geodatabase. This works fine. As a typical example in one case it reads and writes about 120,000 features in 4 minutes.

Now I need to update the process to write to an Oracle SDE instance. Overall it works, its just much slower. For example, the process that took 4 minutes to process 120,000 records in an FGDB takes 18 minutes in Oracle. This alone would be OK. My issue is that I’ve got some processes that take hours in the FGDB.

As part of the updates for Oracle I’ve switched to use of IFeatureClassWrite::Write instead of IFeature::Store that I was using in the FGDB. My understanding is that the FeatureClassWrite doesn't trigger events like Store. However this doesn’t seem to make much difference. Here’s an overview of what the process does.

// Get the target workspace
IWorkspace targetWorkspace = workspaceFactory.OpenFromFile(connectionString, 0);
IWorkpaceEdit workspaceEdit = (IWorkspaceEdit) targetWorkspace;

// Start editing
workspaceEdit.StartEditing(false);
workspaceEdit.StartEditOperation();

// Open the source and target feature classes
IFeatureWorkspace sourceFeaWorkspace = (IFeatureWorkspace) sourceWorkspace;
IFeatureClass sourceClass = sourceFeaWorkspace.OpenFeatureClass(sourceClassName);

IFeatureWorkspace feaWorkspace = (IFeatureWorkspace) targetWorkspace;
IFeatureClass targetClass = feaWorkspace.OpenFeatureClass(targetClassName);
IFeatureClassWrite fcWrite = (IFeatureClassWrite) targetClass;

// Put the target class in load-only mode and apply a schema lock
IFeatureClassLoad fcLoad = (IFeatureClassLoad) targetClass;
ISchemaLock schemaLock = (ISchemaLock) targetClass;
schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
fcLoad.LoadOnlyMode = true;

// Read from the source and write to the target
IFeature targetFea = null;

IQueryFilter queryFilter = new QueryFilter();
IFeatureCursor feaCur = sourceClass.Search(queryFilter,true);
IFeature sourceFea = feaCur.Next();
while (sourceFea != null)
{
targetFea = targetClass.CreateFeature();

// Update the shape and attributes

// Store the target feature
fcWrite.WriteFeature(targetFea);

sourceFea = feaCur.Next();
}

// Stop editing and release lock
workspaceEdit.StopEditing(true);
schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
fcLoad.LoadOnlyMode = false;


I’ve also tried grouping features into an ISet and using IFeatureClassWrite::WriteFeatures. No difference in performance. I’ve also tried using an InsertCursor. No difference in performance.

Is it just the case that writing directly to an Oracle SDE instance is 4 to 5 times slower than writing to an FGDB? Any insights or suggestions at all would be much appreciated.

Thanks,
Ed

Viewing all articles
Browse latest Browse all 1374

Trending Articles