PostgreSQL 固有のモデルインデックスLink to this heading

以下はPostgreSQL固有の django.contrib.postgres.indexes モジュールから利用可能な インデックス です。

BloomIndexLink to this heading

class BloomIndex(*expressions, length=None, columns=(), **options)Link to this definition

bloom インデックスを作成します。

このインデックスアクセスを使用するには、PostgreSQLで bloom 拡張機能を有効にする必要があります。これは、 BloomExtension マイグレーションオペレーションを使用してインストールできます。

length パラメータには、1 から 4096 の整数のビット数を指定して、各インデックスエントリの長さを指定してください。PostgreSQL のデフォルト値は 80 です。

columns 引数は、1から4095までの整数ビットで、最大32個の値を持つタプルまたはリストを取ります。

BrinIndexLink to this heading

class BrinIndex(*expressions, autosummarize=None, pages_per_range=None, **options)Link to this definition

BRIN index を作成します。

autosummarize パラメータを True に設定すると、autovacuum による automatic summarization を有効にできます。

pages_per_range 引数は正の整数を取ります。

BTreeIndexLink to this heading

class BTreeIndex(*expressions, fillfactor=None, deduplicate_items=None, **options)Link to this definition

B-Tree インデックスを作成します。

fillfactor パラメータには、インデックスページがどれだけ詰め込まれるかを調整するために、10 から 100 の整数値を指定してください。PostgreSQL のデフォルト値は 90 です。

deduplicate_items パラメータに真偽値を指定して、重複排除が有効かどうかを制御します。PostgreSQLでは、重複排除はデフォルトで有効になっています。

GinIndexLink to this heading

class GinIndex(*expressions, fastupdate=None, gin_pending_list_limit=None, **options)Link to this definition

gin インデックス を作成します。

To use this index on data types not in the built-in operator classes, you need to activate the btree_gin extension on PostgreSQL. You can install it using the BtreeGinExtension migration operation.

fastupdate パラメータを False に設定すると、PostgreSQL でデフォルトで有効になっている GIN Fast Update Technique を無効にできます。

fastupdate が有効な場合に使用される GIN 保留リストの最大サイズを調整するには、 gin_pending_list_limit パラメータに整数キロバイト数を指定します。

GistIndexLink to this heading

class GistIndex(*expressions, buffering=None, fillfactor=None, **options)Link to this definition

GiSTインデックス を作成します。これらのインデックスは、 spatial_index=True で指定された空間フィールドに自動的に作成されます。これらは、 HStoreField範囲フィールド など他のタイプでも有用です。

To use this index on data types not in the built-in gist operator classes, you need to activate the btree_gist extension on PostgreSQL. You can install it using the BtreeGistExtension migration operation.

インデックスの buffering build を手動で有効または無効にするには、 buffering パラメータを True または False に設定してください。

fillfactor パラメータには、インデックスページがどれだけ詰め込まれるかを調整するために、10 から 100 の整数値を指定してください。PostgreSQL のデフォルト値は 90 です。

HashIndexLink to this heading

class HashIndex(*expressions, fillfactor=None, **options)Link to this definition

ハッシュインデックスを作成します。

fillfactor パラメータには、インデックスページがどれだけ詰め込まれるかを調整するために、10 から 100 の整数値を指定してください。PostgreSQL のデフォルト値は 90 です。

SpGistIndexLink to this heading

class SpGistIndex(*expressions, fillfactor=None, **options)Link to this definition

SP-GiST インデックス を作成します。

fillfactor パラメータには、インデックスページがどれだけ詰め込まれるかを調整するために、10 から 100 の整数値を指定してください。PostgreSQL のデフォルト値は 90 です。

OpClass()Link to this heading

class OpClass(expression, name)Link to this definition

OpClass() 式は、機能インデックス、機能ユニーク制約、または除外制約を定義するために使用できるカスタム operator class と一緒に表す expression を表します。これを使用するには、 INSTALLED_APPS'django.contrib.postgres' を追加する必要があります。name パラメータを operator class の名前に設定します。

例:

Code
Index(
    OpClass(Lower("username"), name="varchar_pattern_ops"),
    name="lower_username_idx",
)

varchar_pattern_ops を使用して Lower('username') にインデックスを作成します:

Code
UniqueConstraint(
    OpClass(Upper("description"), name="text_pattern_ops"),
    name="upper_description_unique",
)

Upper('description') を使って text_pattern_ops を使用してユニーク制約を作成します:

Code
ExclusionConstraint(
    name="exclude_overlapping_ops",
    expressions=[
        (OpClass("circle", name="circle_ops"), RangeOperators.OVERLAPS),
    ],
)

これは circle_ops を使用して circle 上に排他制約を作成します。