| Bug ID Number |
NIM041253 |
| Submitted | January 6, 2009 |
| Last Modified | April 2, 2025 |
| Applies to | No Product Found |
| Version found | 9.3 |
| Version Fixed | N/A |
| Status | Fixed
The bug has been fixed. See the Version Fixed and Additional Information, if applicable, for more information.
|
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