Re: Create lowercase index

Rick
2013-07-03T18:25:53Z

Straight from rails4.0 documentation:
http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html

Creating an index with a specific method

add_index(:developers, :name, using: ''btree'')

generates:

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

Note: only supported by PostgreSQL and MySQL

On Tuesday, July 2, 2013 1:13:15 PM UTC-4, Linus Pettersson
wrote:
>
> Hi
>
> I''m sorting some columns like this:
MyModel.order("LOWER(column) ASC")...
> But these queries are quite slow. I''m on Postgres by the way.
>
> Does Rails support creating a lowercase index for these situations? I know
> Postgres has support for it and I guess I can create one like this (found
> on SO):
>
> execute "CREATE UNIQUE INDEX index_products_on_lower_name ON products
USING btree (lower(name));"
>
> But does Rails have support for creating it? Don''t like to use
execute()
> if there is a better way :)
>
> Cheers,
> Linus
>

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit