NoSQL Zone is brought to you in partnership with:

Ayende Rahien is working for Hibernating Rhinos LTD, a Israeli based company producing developer productivity tools for OLTP applications such as NHibernate Profiler (nhprof.com), Linq to SQL Profiler(l2sprof.com), Entity Framework Profiler (efprof.com) and more. Ayende is a DZone MVB and is not an employee of DZone and has posted 305 posts at DZone. You can read more from them at their website. View Full User Profile

The Importance of Temporary Indexes for Ad Hoc Queries

07.15.2012
| 1093 views |
  • submit to reddit

In RavenDB, when you make an query without explicitly specifying which index you want to use, the query optimizer will select one for you. If none is found that can satisfy your query, the query optimizer will create one that matches your query, but it will do so on a temporary basis. That index will function normally, but if it isn’t used, it will be removed after a while. If it is heavily used, it will be converted to a real index.

I was reminded of this today when I realized that I had a bug in our code that caused a value to be misspelled. There were just a few such documents, and I went into the studio and fixed them manually. I had to use a dynamic query to do so, and I was amused to realize that this is the exact scenario for which we built them. An admin doing ad hoc operations, probably to resolve some bug or issue.

Sometimes, just having things work out the way you planned make for a great day. And hey, this is what I was avoiding:

Published at DZone with permission of Ayende Rahien, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)