lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Dotzour" <>
Subject RE: First search is slow after updating index .. subsequent searches very fast
Date Wed, 20 Dec 2006 22:23:40 GMT
One question about this, Otis... When "warming up" the new searcher,
should the query return a lot of results, or does it matter?  Can I just
do like an ID = X query and get one document back?  Is that sufficient
or is it better to run a query that will get lots of hits?

Thanks again,

-----Original Message-----
From: Otis Gospodnetic [] 
Sent: Wednesday, December 20, 2006 3:28 PM
Subject: Re: First search is slow after updating index .. subsequent
searches very fast

All sounds good.  Opening a new IndexReader can take a bit of time.  If
you use sorting of any kind other than default sorting by relevance,
this delay on the first search is also probably caused by the lazy
FieldCache population.  The cure for that is to open a new
IndexReader/Searcher before you close the old one, warm it up with a
query + sort, and then switch IndexReader/Searchers, closing the old


----- Original Message ----
From: Bryan Dotzour <>
Sent: Wednesday, December 20, 2006 3:59:19 PM
Subject: First search is slow after updating index .. subsequent
searches very fast

I'm investigating some performance issues with the way we're using
Lucene in our web app and am interested if anyone could shed some light
on what might be going on.  Hopefully I can provide enough information,
please let me know if there's more I can give.


We're using Lucene 2.0.0 and I'm currently working with disk-based
indexing (although in production I'll want to be using RAM indexing).
In our environment, we build up our Lucene index at application start up
time and then we optimize the index.  From then on, updates and deletes
to the index occur fairly frequently but we don't optimize until the
middle of the night when the impact would be at its minimum.  After a
while, what I see is that searches will be very fast (~400 ms) until I
make a modification that will require a single document to be
re-indexed.  Immediately after that has occurred, the next search will
take substantially longer (sometimes up to ~25s).  After that search has
run, the next search will be back at the ~400ms time.


Our algorithm for handling the updates is as follows:

1.       open an IndexReader on the directory

2.       delete the document using the reader

3.       close the reader

4.       open an IndexWriter

5.       add the new document using the writer

6.       close the writer


For searches:

1.    We cache off an IndexReader for the index, as well as an
IndexSearcher, which uses that reader
2.    When a search is initiated we check to see if the version of the
index has changed using getCurrentVersion()
3.    If it has changed, we close our IndexSearcher, close the
IndexReader and re-open them both



Anything sound non-standard in that workflow?  Does anyone have an idea
of what might be happening during that slow down?


Thanks for your time,





(For a little more info, here is a very common stack trace snippet that
I gather when the "slow search" is running.  It seems much of the time
is spent in MultiReader or MultiTermDocs)



To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message