Skip to content

PostgreSQL GIN and GiST index support#3706

Closed
chaffeqa wants to merge 3 commits intorails:masterfrom
chaffeqa:master
Closed

PostgreSQL GIN and GiST index support#3706
chaffeqa wants to merge 3 commits intorails:masterfrom
chaffeqa:master

Conversation

@chaffeqa
Copy link
Contributor

Added add_index override in postgresql_adapter to allow for GiST and GIN support.

add_index(:wikis, :body, :gin => true)

Added PostgresqlAdapter indexes() :type support (specifying :btree, :gin, and :gist index types).
NOTE: instead of hacking the IndexDefinition class, I just added a :type attribute to the abstract/schema_definitions.rb

ActiveRecord::Base.connection.indexes(:wikis) #=> #<struct ActiveRecord::ConnectionAdapters::IndexDefinition table=:wikis, name="index_wikis_on_ancestry", unique=false, columns=["ancestry"], lengths=nil, type=:btree>

Added tests for add_index. Updated tests for postgresql/schema_tests to check for index :type.

Let me know if there are other schema related updates I should do. Would gladly do so :)

(refs this old pull )

@jenseng
Copy link
Contributor

jenseng commented Dec 8, 2011

would it be better to just have a :method option (instead of :gist/:gin)? after all, an index can't have more than one method.

this would simplify PostgresqlAdapter#add_index, would support all index types (btree/hash/gist/gin), would allow for user-defined index methods, and make the whole thing future proof.

i personally prefer :type over :method, but that could get confused w/ index_type (i.e. "" or "UNIQUE"). also the postgres docs generally call it method.

@chaffeqa
Copy link
Contributor Author

chaffeqa commented Dec 8, 2011

great call!

will hop on that tomorrow night.

In a side note... I've been reading up on MySQLs full text and indexes... looks like it can use a :method option for the future as well...

@MSch
Copy link
Contributor

MSch commented Feb 8, 2012

Any updates on this? With hstore being added to 4.0 this PR too would be nice.

@carlosantoniodasilva
Copy link
Member

Hey, your pull request does not apply cleanly on master anymore. Would you mind bringing it up-to-date to master, so we can continue the discussion? I agree this could be an interesting addition to 4.0, thanks!

@MSNexploder
Copy link
Contributor

Hey, right now I'm working on this.
Also adding support for MySQL.

New pull request: #6101

@chaffeqa
Copy link
Contributor Author

chaffeqa commented May 1, 2012

Thanks a bunch @MSNexploder
Sadly with my current job I don't really have enough time to work on this. I was hoping the summer would provide more free time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants