lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Dotzour" <>
Subject First search is slow after updating index .. subsequent searches very fast
Date Wed, 20 Dec 2006 20:59:19 GMT
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)



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message