ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • ヘルプ
  • Sign Out
ArcGIS Desktop

ArcGIS Online

組織のマッピング プラットフォーム

ArcGIS Desktop

完全なプロ仕様の GIS

ArcGIS Enterprise

エンタープライズ GIS

ArcGIS for Developers

位置情報利用アプリの開発ツール

ArcGIS Solutions

各種業界向けの無料のテンプレート マップおよびテンプレート アプリケーション

ArcGIS Marketplace

組織で使えるアプリとデータを取得

  • ドキュメント
  • サポート
Esri
  • サイン イン
user
  • マイ プロフィール
  • サイン アウト

ArcMap

  • ホーム
  • はじめに
  • マップ
  • 解析
  • データ管理
  • ツール
  • エクステンション

システム テーブル インデックスの再構築

Standard または Advancedのライセンスで利用可能。

  • インデックスの再構築 (Rebuild Indexes)ツールの使用
  • Python スクリプトのスケジュール設定

データベースでは、インデックスを使用してクエリの述語フィルターに一致する行をすばやく識別します。ほとんどのジオデータベース システム テーブルにはインデックスが作成されていますが、バージョン対応エンタープライズ ジオデータベースの states、state_lineages、および mv_tables_modified システム テーブルでは大量の変更が発生する傾向があり、これらのテーブルのインデックスは高い頻度で再構築する必要があります。ジオデータベース管理者は、[インデックスの再構築 (Rebuild Indexes)] ジオプロセシング ツールを使用して、IBM DB2、Microsoft SQL Server、Oracle、または PostgreSQL に格納されたジオデータベースの各テーブルにインデックスを再構築できます。

大量の編集が行われるバージョン対応登録されたジオデータベースでは、states、state_lineages、および mv_tables_modified の各テーブルのインデックスを夜間に更新できます。これを行うには、[インデックスの再構築 (Rebuild Indexes)] ツールを呼び出す スタンドアロン Python スクリプトを作成し、Windows タスク スケジューラまたは cron ジョブを使用して実行するように、このスクリプトのスケジュールを設定します。

ヒント:

データ所有者が [インデックスの再構築 (Rebuild Indexes)] ツールを使用して、データに属性インデックスと空間インデックスを再構築することもできます。詳細については、「データセットのインデックスの再構築」をご参照ください。

インデックスの再構築 (Rebuild Indexes)ツールの使用

[インデックスの再構築 (Rebuild Indexes)] ツールを使用して states、state_lineages、および mv_tables_modified の各ジオデータベース システム テーブルのインデックスを再構築するには、以下の手順を実行します。

  1. ArcGIS for Desktop を起動し、ジオデータベース管理者でジオデータベースに接続します。
  2. [インデックスの再構築 (Rebuild Indexes)] ジオプロセシング ツールを開きます。

    このツールは [データ管理] ツールボックスの [ジオデータベース管理] ツールセットにあります。

  3. ステップ 1 で作成したデータベース接続を [入力データベース接続] として使用します。
  4. [システム テーブルを含む] チェックボックスをオンにします。
  5. [差分テーブルのみを再構築] をオフにします。
  6. [OK] をクリックして、このツールを実行します。

Python スクリプトのスケジュール設定

スクリプトを実行するには、ジオデータベース管理者としてジオデータベースに接続できる必要があります。接続ファイル (*.sde) を作成して、このファイルをスクリプトから指定するか、接続情報を直接スクリプトに入力することができます。次に、Windows タスク スケジューラまたは Linux の cron デーモンを使用して、スクリプトの実行をスケジュールします。

  1. Python および以下のいずれかの ArcGIS 製品がインストールされているコンピューターに、次のスクリプトのいずれかをコピーします。
    • ArcGIS for Desktop (Standard または Advanced)
    • ArcGIS Engine と Geodatabase Update エクステンション
    • ArcGIS for Server (Standard または Advanced)

    環境に固有の情報に基づいて、スクリプトを変更します。

    このサンプル スクリプトには、Oracle データベースに接続して、states、state_lineages、および mv_tables_modified システム テーブルのインデックスを更新するために必要な情報が含まれています。

    # Name: RSysIdxOracle.py
    # Description: Rebuilds indexes on the states, state_lineages,
    # and mv_tables_modified tables in an enterprise geodatabase
    # in Oracle.
    
    # Author: Esri
    
    # Import system modules
    import sys
    import arcpy
    import os
    
    # Provide connection information
    database_platform = Oracle
    instance = Oracle_instance
    account_authentication = OPERATING_SYSTEM_AUTH | DATABASE_AUTH
    #Leave username and password blank if using OPERATING_SYSTEM_AUTH
    username = gdb_admin_user_name
    password = gdb_admin_password
    version = sde.DEFAULT
    
    
    # Set local variables
    if os.name.lower() == "nt":
       slashsyntax = "\\"
       if os.environ.get("TEMP") == None:
          temp = "c:\\temp"
       else:
          temp = os.environ.get("TEMP")
    else:
       slashsyntax = "/"
       if os.environ.get("TMP") == None:
          temp = "/usr/tmp"
       else:
          temp = os.environ.get("TMP")
    
    Connection_File_Name = temp + slashsyntax + "connection.sde"
    
    # Check for the .sde file and delete it if present
    if os.path.exists(Connection_File_Name):
       os.remove(Connection_File_Name)
    
    #Variable defined within the script; other variable options commented out at the end of the line
    saveUserInfo = "SAVE_USERNAME" #DO_NOT_SAVE_USERNAME
    saveVersionInfo = "SAVE_VERSION" #DO_NOT_SAVE_VERSION
    
    print "Creating database connection file..."
    # Usage: out_folder_path, out_name, database_platform, instance, account_authentication, username, password, saveUserInfo, version, saveVersionInfo
    arcpy.CreateDatabaseConnection_management(temp, "connection.sde", database_platform, instance, account_authentication, username, password, saveUserInfo, version, saveVersionInfo)
    
    # Rebuild indexes on system tables
    arcpy.RebuildIndexes_management(Connection_File_Name, "SYSTEM", "", "ALL")
    print 'Rebuild Complete'
    

    このサンプル スクリプトには、オペレーティング システムで認証された dbo ユーザーを使用して SQL Server に接続し、sde_states、sde_state_lineages、および sde_mv_tables_modified システム テーブルのインデックスを更新するための情報が含まれています。

    # Name: RSysIdxSqlServer.py
    # Description: Rebuilds indexes on the sde_states, sde_state_lineages,
    # and sde_mv_tables_modified tables in an enterprise geodatabase
    # in SQL Server.
    
    # Author: Esri
    
    # Import system modules
    import sys
    import arcpy
    import os
    
    # Provide connection information
    database_platform = SQL_Server
    instance = dbms_instance_name
    account_authentication = OPERATING_SYSTEM_AUTH | DATABASE_AUTH
    database = database_name
    #Leave username and password blank if using OPERATING_SYSTEM_AUTH
    username = gdb_admin_user_name
    password = gdb_admin_password
    version = sde.DEFAULT
    
    
    # Set local variables
    if os.name.lower() == "nt":
       slashsyntax = "\\"
       if os.environ.get("TEMP") == None:
          temp = "c:\\temp"
       else:
          temp = os.environ.get("TEMP")
    else:
       slashsyntax = "/"
       if os.environ.get("TMP") == None:
          temp = "/usr/tmp"
       else:
          temp = os.environ.get("TMP")
    
    Connection_File_Name = temp + slashsyntax + "connection.sde"
    
    # Check for the .sde file and delete it if present
    if os.path.exists(Connection_File_Name):
       os.remove(Connection_File_Name)
    
    #Variable defined within the script; other variable options commented out at the end of the line
    saveUserInfo = "SAVE_USERNAME" #DO_NOT_SAVE_USERNAME
    saveVersionInfo = "SAVE_VERSION" #DO_NOT_SAVE_VERSION
    
    print "Creating database connection file..."
    # Usage: out_folder_path, out_name, database_platform, instance, account_authentication, username, password, saveUserInfo, database, version, saveVersionInfo
    arcpy.CreateDatabaseConnection_management(temp, "connection.sde",  instance, account_authentication, username, password, saveUserInfo, database, version, saveVersionInfo)
    
    # Rebuild indexes on system tables
    arcpy.RebuildIndexes_management(Connection_File_Name, "SYSTEM", "", "ALL")
    print 'Rebuild Complete'
    

    この例では、sde ユーザーは PostgreSQL データベースに接続します。

    # Name: RSysIdxpg.py
    # Description: Rebuilds indexes on the sde_states, sde_state_lineages,
    # and sde_mv_tables_modified tables in an enterprise geodatabase
    # in PostgreSQL.
    
    # Author: Esri
    
    # Import system modules
    import sys
    import arcpy
    import os
    
    # Provide connection information
    database_platform = PostgreSQL
    instance = PostgreSQL_servername
    database = database_name
    account_authentication = DATABASE_AUTH
    username = gdb_admin_user_name
    password = gdb_admin_password
    version = sde.DEFAULT
    
    
    # Set local variables
    if os.name.lower() == "nt":
       slashsyntax = "\\"
       if os.environ.get("TEMP") == None:
          temp = "c:\\temp"
       else:
          temp = os.environ.get("TEMP")
    else:
       slashsyntax = "/"
       if os.environ.get("TMP") == None:
          temp = "/usr/tmp"
       else:
          temp = os.environ.get("TMP")
    
    Connection_File_Name = temp + slashsyntax + "connection.sde"
    
    # Check for the .sde file and delete it if present
    if os.path.exists(Connection_File_Name):
       os.remove(Connection_File_Name)
    
    #Variable defined within the script; other variable options commented out at the end of the line
    saveUserInfo = "SAVE_USERNAME" #DO_NOT_SAVE_USERNAME
    saveVersionInfo = "SAVE_VERSION" #DO_NOT_SAVE_VERSION
    
    print "Creating database connection file..."
    # Usage: out_folder_path, out_name, database_platform, instance, account_authentication, username, password, saveUserInfo, database, version, saveVersionInfo
    arcpy.CreateDatabaseConnection_management(temp, "connection.sde",  instance, account_authentication, username, password, saveUserInfo, database, version, saveVersionInfo)
    
    # Rebuild indexes on system tables
    arcpy.RebuildIndexes_management(Connection_File_Name, "SYSTEM", "", "ALL")
    print 'Rebuild Complete'
    

    この例では、sde ユーザーは DB2 データベースに接続します。

    # Name: RSysIdxDb2.py
    # Description: Rebuilds indexes on the states, state_lineages,
    # and mv_tables_modified tables in an enterprise geodatabase
    # in DB2.
    
    # Author: Esri
    
    # Import system modules
    import sys
    import arcpy
    import os
    
    # Provide connection information
    database_platform = DB2
    instance = odbc_dsn
    account_authentication = OPERATING_SYSTEM_AUTH | DATABASE_AUTH
    #Leave username and password blank if using OPERATING_SYSTEM_AUTH
    username = gdb_admin_user_name
    password = gdb_admin_password
    version = sde.DEFAULT
    
    
    # Set local variables
    if os.name.lower() == "nt":
       slashsyntax = "\\"
       if os.environ.get("TEMP") == None:
          temp = "c:\\temp"
       else:
          temp = os.environ.get("TEMP")
    else:
       slashsyntax = "/"
       if os.environ.get("TMP") == None:
          temp = "/usr/tmp"
       else:
          temp = os.environ.get("TMP")
    
    Connection_File_Name = temp + slashsyntax + "connection.sde"
    
    # Check for the .sde file and delete it if present
    if os.path.exists(Connection_File_Name):
       os.remove(Connection_File_Name)
    
    #Variable defined within the script; other variable options commented out at the end of the line
    saveUserInfo = "SAVE_USERNAME" #DO_NOT_SAVE_USERNAME
    saveVersionInfo = "SAVE_VERSION" #DO_NOT_SAVE_VERSION
    
    print "Creating database connection file..."
    # Usage: out_folder_path, out_name, database_platform, instance, account_authentication, username, password, saveUserInfo, version, saveVersionInfo
    arcpy.CreateDatabaseConnection_management(temp, "connection.sde", database_platform, instance, account_authentication, username, password, saveUserInfo, version, saveVersionInfo)
    
    # Rebuild indexes on system tables
    arcpy.RebuildIndexes_management(Connection_File_Name, "SYSTEM", "", "ALL")
    print 'Rebuild Complete'
    
  2. ユーザーの接続情報を含むようにスクリプトを変更した後、スクリプトを毎晩指定した時刻に実行するようにスケジュールします。
    • Windows では、コントロール パネルからタスク スケジューラを開き、ウィザードを使用してタスクのスケジュールを設定します。実行するプログラムを指定するときに、作成した Python スクリプトを参照します。
    • Linux では、スクリプトを実行する曜日と時刻の情報を含む cron テキスト ファイルを作成し、crontab プログラムを使用してファイルを cron に読み込みます。

      たとえば、次の情報では、毎週水曜の午後 10 時に Python スクリプト (rsysidxdb2.py) を実行するように設定されます。:

      0 22 * * 3 /usr/bin/rsysidxdb2.py

      cron の使用方法については、Linux のインストールに付属の man ページをご参照ください。

ArcGIS Desktop

  • ホーム
  • ドキュメント
  • サポート

ArcGIS プラットフォーム

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

Esri について

  • 会社概要
  • 採用情報
  • Esri ブログ
  • ユーザ カンファレンス
  • デベロッパ サミット
Esri
ご意見・ご感想をお寄せください。
Copyright © 2019 Esri. | プライバシー | リーガル