BloomIndex
This class provides a PostgreSQL-specific Bloom index implementation for database fields. It supports indexing up to 32 fields and allows for customization of the index length and individual column bit settings. The class ensures data integrity by validating that configuration parameters fall within the specific constraints required by the underlying database engine.
Attributes
| Attribute | Type | Description |
|---|---|---|
| suffix | string = "bloom" | The storage engine suffix used for the index name generation, set to "bloom". |
| length | integer | The total length of the bloom filter in kilobytes, which must be an integer between 1 and 4096. |
| columns | list or tuple = () | A list or tuple of integers between 1 and 4095 specifying the number of bits generated for each indexed field. |
Constructor
Signature
def BloomIndex(
*expressions: any,
length: int = None,
columns: list|tuple = (),
**kwargs: any
)
Parameters
| Name | Type | Description |
|---|---|---|
| *expressions | any | Positional arguments representing the fields or expressions to be indexed. |
| length | int = None | The length of the bloom filter, must be between 1 and 4096. |
| columns | `list | tuple` = () |
| **kwargs | any | Additional keyword arguments passed to the parent PostgresIndex class. |
Signature
def BloomIndex(
*expressions: any,
length: int,
columns: list|tuple,
**kwargs: any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| *expressions | any | Positional arguments representing the fields or expressions to be indexed. |
| length | int | The total length of the bloom filter in kilobytes, ranging from 1 to 4096. |
| columns | `list | tuple` |
| **kwargs | any | Additional keyword arguments passed to the base PostgresIndex class. |
Methods
deconstruct()
@classmethod
def deconstruct() - > tuple
Returns a 3-tuple containing the full import path, positional arguments, and keyword arguments required to recreate the index instance.
Returns
| Type | Description |
|---|---|
tuple | A tuple of (path, args, kwargs) used by Django's migration framework to serialize the index. |
get_with_params()
@classmethod
def get_with_params() - > list
Generates a list of storage parameter strings specifically for the 'WITH' clause of a PostgreSQL CREATE INDEX statement.
Returns
| Type | Description |
|---|---|
list | A list of formatted strings such as 'length = 128' or 'col1 = 5' representing bloom filter configuration. |