Skip to main content

GistIndex

This class represents a Generalized Search Tree (GiST) index for PostgreSQL databases. It allows for the creation of specialized indexes on complex data types and supports configurable parameters such as buffering and fillfactor. The class integrates with the database backend to manage index construction and deconstruction within the schema.

Attributes

AttributeTypeDescription
suffixstring = gistThe storage engine suffix used for naming the index in the database.
bufferingbooleanDetermines whether the buffering build technique is used to build the index, accepting a boolean to toggle the feature on or off.
fillfactorintegerSpecifies the fill factor percentage for the index to control how packed the index pages are during creation.

Constructor

Signature

def GistIndex(
*expressions: any,
buffering: boolean = None,
fillfactor: integer = None,
**kwargs: any
) - > null

Parameters

NameTypeDescription
*expressionsanyPositional arguments representing the expressions or columns to be indexed.
bufferingboolean = NoneOptional boolean to enable or disable the GiST buffering build algorithm.
fillfactorinteger = NoneOptional integer between 10 and 100 representing the packing density of index pages.
**kwargsanyAdditional keyword arguments passed to the base PostgresIndex class.

Methods


deconstruct()

@classmethod
def deconstruct() - > tuple

Returns a 3-tuple containing the import path, positional arguments, and keyword arguments required to recreate the GistIndex instance. This is primarily used by Django's migration framework to serialize the index state.

Returns

TypeDescription
tupleA tuple of (path, args, kwargs) representing the serialized state of the index.

get_with_params()

@classmethod
def get_with_params() - > list

Generates a list of storage parameter strings used in the SQL 'WITH' clause for index creation. This converts the buffering and fillfactor attributes into their PostgreSQL-compatible string representations.

Returns

TypeDescription
listA list of strings containing the formatted 'buffering' and 'fillfactor' parameters for the SQL statement.