Skip to content

Add support for PostgreSQL index access methods (gist, spgist, brin, hash)#1053

Draft
dereuromark wants to merge 3 commits into5.xfrom
feature/postgres-index-access-methods
Draft

Add support for PostgreSQL index access methods (gist, spgist, brin, hash)#1053
dereuromark wants to merge 3 commits into5.xfrom
feature/postgres-index-access-methods

Conversation

@dereuromark
Copy link
Member

Summary

This PR adds support for additional PostgreSQL index access methods beyond the existing GIN support:

  • GiST (Generalized Search Tree) - for geometric data, range types, full-text search
  • SP-GiST (Space-Partitioned GiST) - for data with natural clustering (IP addresses, phone numbers)
  • BRIN (Block Range Index) - for large, naturally-ordered tables like time-series data
  • Hash - for simple equality comparisons

Additionally, this adds support for specifying operator classes (opclass) on index columns, which is useful for specialized index configurations like trigram similarity searches with gist_trgm_ops.

Changes

  • Add Index::GIN, Index::GIST, Index::SPGIST, Index::BRIN, Index::HASH constants
  • Add opclass option to Index class for specifying operator classes
  • Generalize PostgresAdapter::getIndexSqlDefinition() to support all access methods
  • Add comprehensive tests for each new index type
  • Update documentation with examples for all PostgreSQL index access methods

Usage

// GIN index for JSONB
$table->addIndex('tags', ['type' => 'gin']);

// GiST index with operator class for trigram search
$table->addIndex('name', [
    'type' => 'gist',
    'opclass' => ['name' => 'gist_trgm_ops'],
]);

// BRIN index for time-series data
$table->addIndex('recorded_at', ['type' => 'brin']);

// SP-GiST index for IP addresses
$table->addIndex('client_ip', ['type' => 'spgist']);

// Hash index for equality lookups
$table->addIndex('session_id', ['type' => 'hash']);

Refs cakephp/phinx#1823

…hash)

- Add Index constants for GIN, GIST, SPGIST, BRIN, and HASH access methods
- Add opclass option for specifying operator classes on index columns
- Generalize PostgresAdapter to support all access method types
- Add tests for each new index type
- Update documentation with examples for all PostgreSQL index types

Refs cakephp/phinx#1823
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant