whoosh icon indicating copy to clipboard operation
whoosh copied to clipboard

[RFC] Give SegmentWriter a cachable Searcher

Open asedeno opened this issue 3 years ago • 0 comments

When repeatedly calling update_document(), each call instantiates a Searcher, which is expensive. The SegmentWriter already has a write lock on the index, so if the conditions are right, let's cache a Searcher, override its close() method to keep it open, and close it on _finish() if it's around.

I think this is safe, but I don't know enough about whoosh to be certain. All tests are still passing, and I didn't break any django-haystack tests with this change either.

asedeno avatar Jun 16 '21 00:06 asedeno