Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

The Importance of Temporary Indexes for Ad Hoc Queries

DZone's Guide to

The Importance of Temporary Indexes for Ad Hoc Queries

· Database Zone ·
Free Resource

RavenDB vs MongoDB: Which is Better? This White Paper compares the two leading NoSQL Document Databases on 9 features to find out which is the best solution for your next project.  

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:

Get comfortable using NoSQL in a free, self-directed learning course provided by RavenDB. Learn to create fully-functional real-world programs on NoSQL Databases. Register today.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}