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

Learn how to create flexible schemas in a relational database using SQL for JSON.

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:

Create flexible schemas using dynamic columns for semi-structured data. Learn how.

Topics:

Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}