Knowledge Base - Technical Articles
FAQ: How can ArcSDE performance be improved?
| Article ID: | 24518 |
|---|---|
| Software: | ArcSDE 8.3, 9.0, 9.1, 9.2, 9.3, 9.3.1 |
| Platforms: | N/A |
Question
Answer
Below are scripts (for Oracle and SQL Server) that perform the following:
1) Rebuild every index by any user that owns SDE data.
2) Analyzes the schema of each user that owns SDE data.
These scripts are not a solution for every performance related ArcSDE issue,
but are something that should be done on a regular basis as scheduled maintenance.
Oracle 8i/9i/10G (needs to be run as the 'SYS' user) :
SET SERVEROUTPUT ON
DECLARE
CURSOR Owner_Cur IS
SELECT DISTINCT(OWNER) owner
FROM sde.table_registry
ORDER BY owner;
CURSOR Index_Cur IS
SELECT owner, index_name
FROM dba_indexes
WHERE owner IN
(SELECT DISTINCT(owner)
FROM sde.table_registry)
AND INDEX_TYPE = 'NORMAL'
ORDER BY owner, index_name;
SQL_STMT VARCHAR2(200);
BEGIN
DBMS_OUTPUT.ENABLE (100000);
FOR IndexRec IN Index_Cur LOOP
SQL_STMT := ('ALTER INDEX ' || IndexRec.owner || '.' || IndexRec.index_name || ' REBUILD');
DBMS_OUTPUT.PUT_LINE(SQL_STMT);
EXECUTE IMMEDIATE SQL_STMT;
DBMS_OUTPUT.NEW_LINE;
END LOOP;
FOR OwnerRec IN Owner_Cur LOOP
DBMS_OUTPUT.PUT_LINE('Analyzing schema : ' || OwnerRec.owner);
DBMS_STATS.GATHER_SCHEMA_STATS(OwnerRec.owner);
DBMS_OUTPUT.NEW_LINE;
END LOOP;
END;
/
SQL Server 2000/2005 - Single Database Model (needs to be run as the 'SA' user or as a 'DBO' user - depending on how the SDE
Respository has been created) :
-- Rebuild indexes on tables for all owners in the table registry.
-- ***************************************************************
-- Run under the Database that contains the SDE Repository tables.
-- If the SDE schema is owned by 'DBO', change:
-- select distinct owner from SDE.sde_table_registry
-- to
-- select distinct owner from DBO.sde_table_registry
use <Admin_Database>
Declare @OwnerName varchar(50)
Declare @TableName varchar(50)
Declare @QualifiedName varchar(100)
Declare OwnerCursor cursor for
select distinct owner from SDE.sde_table_registry
open OwnerCursor
Fetch OwnerCursor into @OwnerName
while (@@fetch_status=0)
begin
Declare TableCursor cursor for
-- Get all the tables for this user
select so.name from sysobjects so join sysusers su on so.uid = su.uid where type = 'U' and su.name = @OwnerName
open TableCursor
Fetch TableCursor into @TableName
while (@@fetch_status=0)
begin
set @QualifiedName = @OwnerName + '.' + @TableName
print 'Rebilding indexes on : ' + @QualifiedName
dbcc dbreindex(@QualifiedName) WITH NO_INFOMSGS
print 'Updating Statistics on: ' + @QualifiedName
EXEC ('UPDATE STATISTICS ' + @QualifiedName )
print ''
Fetch TableCursor into @TableName
end
Fetch OwnerCursor into @OwnerName
close TableCursor
Deallocate TableCursor
end
close OwnerCursor
Deallocate OwnerCursor
SQL Server 2000/2005 - Multiple Database Model (needs to be run as the 'SA' user or as a 'DBO' user - depending on how the SDE
Respository has been created) :
-- Rebuild indexes on tables for all owners in the table registry.
-- ***************************************************************
-- Run under the Database that contains the SDE Repository tables.
-- If the SDE schema is owned by 'DBO', change:
-- select distinct owner from SDE.sde_table_registry
-- to
-- select distinct owner from DBO.sde_table_registry
-- In a Multiple Database Model, you need to run this script in
-- every database that contains data registered with ArcSDE.
use <Database_where_spatial_data_resides>
Declare @OwnerName varchar(50)
Declare @TableName varchar(50)
Declare @QualifiedName varchar(100)
Declare OwnerCursor cursor for
select distinct owner from SDE.SDE.sde_table_registry
open OwnerCursor
Fetch OwnerCursor into @OwnerName
while (@@fetch_status=0)
begin
Declare TableCursor cursor for
-- Get all the tables for this user
select so.name from sysobjects so join sysusers su on so.uid = su.uid where type = 'U' and su.name = @OwnerName
open TableCursor
Fetch TableCursor into @TableName
while (@@fetch_status=0)
begin
set @QualifiedName = @OwnerName + '.' + @TableName
print 'Rebilding indexes on : ' + @QualifiedName
dbcc dbreindex(@QualifiedName) WITH NO_INFOMSGS
print 'Updating Statistics on: ' + @QualifiedName
EXEC ('UPDATE STATISTICS ' + @QualifiedName )
print ''
Fetch TableCursor into @TableName
end
Fetch OwnerCursor into @OwnerName
close TableCursor
Deallocate TableCursor
end
close OwnerCursor
Deallocate OwnerCursor
select distinct(database_name) from SDE.SDE.sde_table_registry;
go
Related Information
- Poor multi-version SQL performance when doing queries
Maintaining SQL performance with versioned queries when having a large number of edits and long lineages. - Poor multi-version SQL performance when doing versioned queries
Poor multi-version SQL performance when doing versioned queries. The following procedures are suggestions to maintain SQL performance with versioned queries. - Poor compress performance
Poor performance while performing a compress operation. - ArcGIS 9.2 Desktop Help: Rebuilding indexes on an ArcSDE Personal or Workgroup geodatabase
Created: 2/14/2003
Last Modified: 7/18/2011
By craiglees - 02/02/2012 10:43 AM
Great article! It helped a lot!
Running this script (at the recommendation of Tech Support) fixed my performance problem. Suggest two updates: 1. There is an error in the SQL Server 2000/2005 - Multiple Database Model script. The line "select distinct owner from SDE.SDE.sde_table_registry" has one too many "SDE.". If you delete one, the script should execute without error. 2. I ran this on a v10 GDB and it worked; but this version isn't included in the software list at the top of the article.
Rating: