# Performance and autocomplete

**URL:** <https://www.ruby-forum.com/t/performance-and-autocomplete/85938>\
**Category:** Rails\
**Created:** [February 17, 2007, 9:27pm UTC](https://www.ruby-forum.com/t/performance-and-autocomplete/85938 "2007-02-17T21:27:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [February 17, 2007, 9:27pm UTC](https://www.ruby-forum.com/t/performance-and-autocomplete/85938/1 "2007-02-17T21:27:01Z")

</div>

hi, how is the performance of the autocomplete fields with a very high  
number of items ?  
for example how does autocomplete for user nick work with a database  
with 500’000/1’000’000 users?

---

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [February 19, 2007, 10:56pm UTC](https://www.ruby-forum.com/t/performance-and-autocomplete/85938/2 "2007-02-19T22:56:09Z")

</div>

nick wrote:

> hi, how is the performance of the autocomplete fields with a very high  
> number of items ?  
> for example how does autocomplete for user nick work with a database  
> with 500’000/1’000’000 users?

anyone?

---

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [February 19, 2007, 11:02pm UTC](https://www.ruby-forum.com/t/performance-and-autocomplete/85938/3 "2007-02-19T23:02:00Z")

</div>

On Feb 19, 2007, at 1:56 PM, nick wrote:

> nick wrote:
> 
> > hi, how is the performance of the autocomplete fields with a very  
> > high  
> > number of items ?  
> > for example how does autocomplete for user nick work with a database  
> > with 500’000/1’000’000 users?
> 
> anyone?

I guess that depends on the size of each record, the type of  
database you use and what indexes you have set. But in general  
autocomplete uses a LIKE query which is definitely slower on a lot of  
records.

Really the only way you are going to know is to make sonme  
benchmarks. Implement a simple autocomplete and try it against a db  
with 1Mil rows.

Cheers-

– Ezra Z.  
– Lead Rails Evangelist  
– removed\_email\_address@domain.invalid  
– Engine Y., Serious Rails Hosting  
– (866) 518-YARD (9273)

---

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [February 19, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/performance-and-autocomplete/85938/4 "2007-02-19T23:04:01Z")

</div>

This isn’t a Rails question, more a database one.  
If you have an index on the field you’re searching, it will be much  
faster  
than if not. Also look into fulltext indexes if using MySQL.

ed

---

<div class="post-metadata">

**Author:** ![nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f9ae1b/32.png) [@nick](https://www.ruby-forum.com/u/nick)\
**Post date:** [February 19, 2007, 11:50pm UTC](https://www.ruby-forum.com/t/performance-and-autocomplete/85938/5 "2007-02-19T23:50:09Z")

</div>

On Feb 19, 2007, at 10:56 PM, nick wrote:

> nick wrote:
> 
> > hi, how is the performance of the autocomplete fields with a very  
> > high  
> > number of items ?  
> > for example how does autocomplete for user nick work with a database  
> > with 500’000/1’000’000 users?
> 
> anyone?

It depends on the query. Remember that you can write a custom method  
that responds to autocompletion, so the efficiency of autocompletion  
will become the efficiency of that method. If you base the query in  
LIKE perhaps performance (of the query) is poor, if you use ferret  
instead it will be surely better. You see, the point is not  
autocompletion itself, but the action behind it.

– fxn
