# How to create index using btree

**URL:** <https://www.ruby-forum.com/t/how-to-create-index-using-btree/152379>\
**Category:** Rails\
**Created:** [November 3, 2008, 11:47am UTC](https://www.ruby-forum.com/t/how-to-create-index-using-btree/152379 "2008-11-03T11:47:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geekforaday-Learner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c6cbf5/32.png) [@Geekforaday-Learner](https://www.ruby-forum.com/u/Geekforaday-Learner)\
**Post date:** [November 3, 2008, 11:47am UTC](https://www.ruby-forum.com/t/how-to-create-index-using-btree/152379/1 "2008-11-03T11:47:04Z")

</div>

Hi,

I want to add a migration to create an index using btree , googled a  
little but couldn’t find anything thats relevant.

is this possible in rails ? or is there a work around ?

appreciate your help , thanks

-CG

---

<div class="post-metadata">

**Author:** ![Geekforaday-Learner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c6cbf5/32.png) [@Geekforaday-Learner](https://www.ruby-forum.com/u/Geekforaday-Learner)\
**Post date:** [November 3, 2008, 1:28pm UTC](https://www.ruby-forum.com/t/how-to-create-index-using-btree/152379/2 "2008-11-03T13:28:11Z")

</div>

On Nov 3, 9:46 pm, Geekforaday-Learnerforlifetime  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> I want to add a migration to create an index using btree , googled a  
> little but couldn’t find anything thats relevant.
> 
> is this possible in rails ? or is there a work around ?
> 
> appreciate your help , thanks
> 
> -CG

I think btree is a fairly common default. For instance it’s the  
default in postgres, right?  
So if you just used the rails ‘add\_index’ you’d get a btree index.  
It looks like add\_index doesn’t pass on extra options though (there  
might be some  
method that does this in rails I just don’t know it). So if you needed  
to  
specify the index method, you might have to execute the sql manually  
in your migration.  
YourARClass.connection.execute(‘CREATE INDEX … USING btree…’)  
You’ll have to consult your db docs to establish its capabilities and  
sql to use.

–  
Daniel B.
