chriseldredge / Lucene.Net.Linq

LINQ provider to run native queries on a Lucene.Net index
Other
151 stars 66 forks source link

LuceneDataProvider meant for single instance? #71

Closed knavet closed 9 years ago

knavet commented 9 years ago

Just curious if the object instance for the LuceneDataProvider class should be maintained per AppInstance, or initialised each time we need to call it?

Not sure if there will be performance overhead?

chriseldredge commented 9 years ago

A single instance of LuceneDataProvider should be kept and reused for the duration of the time that LINQ queries will be executed. Creating a new instance is somewhat expensive, causing new index readers and searchers to be created and losing out on any caching from previously executed queries.

LuceneDataProvider and the sessions and IQueryables that it creates are meant to be thread safe so it's perfectly fine to have multiple threads executing on the index around the same time.