When you want to look up a specific word in a 500-page paper tome, where do
you look? That's the same idea as database indexes =)

On Thu, Jul 7, 2011 at 09:04, Walter Lee Davis <wa...@wdstudio.com> wrote:

>
> On Jul 7, 2011, at 7:28 AM, Rodrigo Ruiz wrote:
>
>  What is add_index for?
>>
>> Someone told me it was to add indexes to the database, but I still dont
>> know what indexes are... first I thought they where other columns of the
>> table, but apparently not.
>>
>
> Indexes are a feature of the relational database. One way they work is to
> organize common query features (sort by date added, for example) in the
> database's structure so that they can happen much more quickly than a simple
> brute-force approach could do. Other types of indexes can enforce uniqueness
> (only one copy of this e-mail address may be added ever) at a fundamental
> level.
>
> Adding an index to a column can return dramatic speed improvements on
> reads, at the expense of slightly longer write times. Like anything, it's a
> trade-off.
>
> Like anything to do with the raw database design, you'll have to read up on
> the specifics of your particular RDBMS to figure out which sort of index
> structure makes the most sense for your application. If you have access to
> someone who is a DBA, they can tell you lots of useful tricks that you might
> use.
>
> But always, add an index (for speed) when you are tuning, not before. An
> index for uniqueness you can add if it makes sense in your design.
>
> Walter
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to 
> rubyonrails-talk@googlegroups.**com<rubyonrails-talk@googlegroups.com>
> .
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscribe@**googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at http://groups.google.com/**
> group/rubyonrails-talk?hl=en<http://groups.google.com/group/rubyonrails-talk?hl=en>
> .
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to