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
| Attribute | Type | Description |
|---|---|---|
| suffix | string = gist | The storage engine suffix used for naming the index in the database. |
| buffering | boolean | Determines whether the buffering build technique is used to build the index, accepting a boolean to toggle the feature on or off. |
| fillfactor | integer | Specifies 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
| Name | Type | Description |
|---|---|---|
| *expressions | any | Positional arguments representing the expressions or columns to be indexed. |
| buffering | boolean = None | Optional boolean to enable or disable the GiST buffering build algorithm. |
| fillfactor | integer = None | Optional integer between 10 and 100 representing the packing density of index pages. |
| **kwargs | any | Additional 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
| Type | Description |
|---|---|
tuple | A 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
| Type | Description |
|---|---|
list | A list of strings containing the formatted 'buffering' and 'fillfactor' parameters for the SQL statement. |