BrinIndex
This class represents a Block Range Index (BRIN) for PostgreSQL databases, designed for handling very large tables where data has a natural correlation with physical storage order. It allows for the configuration of index-specific parameters such as autosummarization and the number of pages per range. The class provides methods to manage these parameters and integrate them into the database's index creation process.
Attributes
| Attribute | Type | Description |
|---|---|---|
| suffix | string = "brin" | The storage engine suffix used for naming the index on the database. |
| autosummarize | boolean | Defines whether the index should automatically summarize a range when a new page is filled. |
| pages_per_range | integer | The number of table pages that make up one block range for the index, which must be a positive integer. |
Constructor
Signature
def BrinIndex(
*expressions: any,
autosummarize: boolean = None,
pages_per_range: integer = None,
**kwargs: any
)
Parameters
| Name | Type | Description |
|---|---|---|
| *expressions | any | Positional arguments representing the expressions or columns to be indexed. |
| autosummarize | boolean = None | Defines whether the index should be automatically summarized when a new page range is filled. |
| pages_per_range | integer = None | The number of table pages that make up one block range in the index; must be a positive integer. |
| **kwargs | any | Additional keyword arguments passed to the parent PostgresIndex class. |
Methods
deconstruct()
@classmethod
def deconstruct() - > tuple
Returns a 3-tuple containing the path to the class, positional arguments, and keyword arguments including BRIN-specific settings for serialization.
Returns
| Type | Description |
|---|---|
tuple | A tuple of (path, args, kwargs) used to reconstruct the index instance during migrations. |
get_with_params()
@classmethod
def get_with_params() - > list
Generates a list of SQL parameter strings for the BRIN index, such as autosummarize and pages_per_range settings.
Returns
| Type | Description |
|---|---|
list | A list of strings representing the WITH clause parameters for the PostgreSQL CREATE INDEX statement. |