add_index using: :btree

add_index "table_name", ["column_name"], name: "index_table_name_on_column_name", using: :btree

Generate

CREATE INDEX index_developers_on_name ON developers USING btree (name) -- PostgreSQL
CREATE INDEX index_developers_on_name USING btree ON developers (name) -- MySQL

Note: only supported by PostgreSQL and MySQL

The database stores the value indexed as a B-Tree key, and the record pointer as a B-Tree value.

In InnoDB, the record pointer is the value of the PRIMARY KEY.

 

Default mysql index is btree ? https://stackoverflow.com/questions/1687910/advantage-of-btree

ref : https://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/add_index,

https://stackoverflow.com/questions/2362667/how-b-tree-indexing-works-in-mysql

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s