laptop and a wrench

Bug

Using 'pTablesort.Sort Nothing' in ArcSDE 9.3 or 9.2 takes 15 minutes in ArcObjects code.

Last Published: August 25, 2014 No Product Found
Bug ID Number NIM041253
SubmittedJanuary 6, 2009
Last ModifiedApril 2, 2025
Applies toNo Product Found
Version found9.3
Version FixedN/A
StatusFixed

Description

**This issue has been resolved in ArcGIS (Desktop, Engine, Server) 9.3.1 Service Pack 2.**

ArcGIS 9.2 introduced an additional query to count the number of rows in the objectclass referenced in the query filter when using the ITableSort::Sort method.

Executing a count(*) statement against a versioned feature class can consume a lot of DBMS resources to return the result and can impact application performance.

This behavior only happens when working with ArcSDE geodatabase data sources.

Cause

The following ArcObjects code block demonstrates how to use the ITableSort interface and the call to the sort method.

The example opens the feature class PRIMARY_OVERHEAD, defines a query filter where the feederid equals 817023, and defines the tablesort properties.
 
Code:
Dim pTablesort As ITableSort

Set pTable = pFeatureWorkspace.OpenTable("PRIMARY_OVERHEAD")

Set pQueryFilter = New QueryFilter
pQueryFilter.WhereClause = "feederid = 817023"

Set pTablesort = New esriGeoDatabase.TableSort

With pTablesort
  .Fields = "OBJECTID"
  .Ascending("OBJECTID") = True
  Set .QueryFilter = pQueryFilter
  Set .Table = pTable
End With

pTablesort.Sort Nothing

When pTablesort.Sort is called, the method executes the additional count(*) query in the DBMS, which can potentially impact performance.

Workaround

If the application is being impacted by the additional query being executed, do not use the ITableSort::Sort method.

Instead, use a search cursor.
 
Code:
Set pCursor = pTable.Search(pQueryFilter, False)
Set pRow = pCursor.NextRow
 

    Steps to Reproduce

    Bug ID: NIM041253

    Software:

    • No Product Found

    Get notified when the status of a bug changes

    Download the Esri Support App

    Related Information

    Discover more on this topic

    Get help from ArcGIS experts

    Contact technical support

    Download the Esri Support App

    Go to download options