Forum: Ferret imdex.update is 10 times slower than index.add_doc. Normal?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Sergei S. (Guest)
on 2006-05-20 00:04

I am seeing that

doc = index['mykey']
index.update 'mykey', doc

is about 10 times slower than
doc =
doc['id'] = 'mykey'
index << doc

It looks like #update is _much_ slower that #<<. Is it as expected?

David B. (Guest)
on 2006-05-20 04:11
(Received via mailing list)
On 5/20/06, Sergei S. <removed_email_address@domain.invalid> wrote:
> index << doc
> It looks like #update is _much_ slower that #<<. Is it as expected?

Hi Sergei,

Yes, it is expected. When you use update it  has to lookup the
document with the same id. It then checks each field in the document
to see which fields have been changed and updates then. It deletes the
old document and adds the new one.  This also means that it has to
open an IndexReader and then closes it and opens an IndexWriter. This
is a lot of processing. If you want fast update then you need to do it
yourself. Just adding a document doesn't even open and IndexReader so
it is going to be faster then updating a document no matter how you do
it. The fastest way to update documents is in a batch. So if you want
to update 10 documents., delete all 10 together, then add the 10
updated documents together.

Hope that helps,
This topic is locked and can not be replied to.