[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how quick is .split()?

luke

7/7/2005 8:58:00 AM


hi all

i'm about to enter 300-500 words into a mysql database, which a rails app
will retrieve. i'm wondering which method would be quicker for a server to
perform:

a) retrieving individual words from 300-500 rows in the database, one to a
row.

or

b) have only one row in the table and this is a concatenated string of all
the keywords, which is .split(), with ruby retrieving the values that way.

i was about to ask this to the mysql group, but then thought that it's more
a question about the speed of the ruby .split() method perhaps :)

thanks
luke


1 Answer

Robert Klemme

7/7/2005 10:14:00 AM

0

luke wrote:
> hi all
>
> i'm about to enter 300-500 words into a mysql database, which a rails
> app will retrieve. i'm wondering which method would be quicker for a
> server to perform:
>
> a) retrieving individual words from 300-500 rows in the database, one
> to a row.
>
> or
>
> b) have only one row in the table and this is a concatenated string
> of all the keywords, which is .split(), with ruby retrieving the
> values that way.
>
> i was about to ask this to the mysql group, but then thought that
> it's more a question about the speed of the ruby .split() method
> perhaps :)

Honestly, I would not make performance the paramount criterium here. As
you describe it it sounds as words must be processed separately so I'd
store them as such in the db. Advantages:

- you can create an index on the word column if you need that (maybe
later)

- rows don't grow too long

But maybe the database is not the proper place to store these words at
all. Maybe marshalling an array into a file is better? Are these words
constant? Are they part of the application? These are the questions I'd
ask.

Kind regards

robert