using magma for autocompletion

Miguel Enrique Cobá Martinez miguel.coba at gmail.com
Sun Nov 8 23:21:02 UTC 2009


El dom, 08-11-2009 a las 11:17 -0800, Ross Boylan escribió:
> I'm thinking of using magma for autocompletion, and this raises some
> questions.
> 
> First, if I put the query in a separate smalltalk process and then kill
> it before it completes (e.g., because there are new characters), can
> this cause any harm?
> 
> Second, the typical scenario would be that one additional character is
> typed.  What's the most efficient way to handle this using magma
> indices?  I could simply give a new query, or I could query the results
> of my previous query.

I think that the performance will kill your app. Even the popular sites
that use autocompletition, like google or any ruby on rails site, don't
use direct DB hit for each posible autocompletition match.
It is better to use a cache of words, maybe rebuilding the cache list
from your real database (in magma you can even use a read only magma
node, check the High Availability setup, for this rebuild, without
affecting the "write" database) every night or so.

Think about this, the autocompletition is just a "nice" feature for the
user, but not the central part of your app. And if you use all the magma
resources just for searching posible matches, the real data that must be
written and read to magma, must wait for all the querys to finish before
they can be serialized to the DB.


> I assume that once I had more characters than the string index held I
> would work strictly with the results of previous queries.
> 
> Third, I could use special search structures (e.g., TSTree from the
> BTree package) oriented to this problem.  Would that be a good idea?
> Should I persist those search trees?

Not, as they will change any time and you'll get a big performance hit
in magma for deleting the old one and storing the new one.

Cheers
-- 
Miguel Cobá
http://miguel.leugim.com.mx



More information about the Magma mailing list