RavenDB 4.1 FeaturesExplain that choice

time to read 2 min | 277 words

One of the things that we do in RavenDB is try to expose as much as possible the internal workings and logic inside RavenDB. In this case, the relevant feature we are trying to expose is the inner working of the query optimizer.

Consider the following query, running on a busy system.

image

This will go to query optimizer, that needs to select the appropriate index to run this query on. However, this process is somewhat of a black box from the outside. Let me show you how RavenDB externalize that decision.

image

You can see that there were initially three index candidates for this. The first one doesn’t index FirstName, so it was ruled out immediately. That gave us a choice of two suitable indexes.

The query optimizer selected the index that has the higher number of fields. This is done to route queries from narrower indexes so they will be retired sooner.

This is a simple case, there are many other factors that may play into the query optimizer decision, such as when an index is stale because it was just created. The query optimizer will then choose another index until the stale index catch up with all its work.

To be honest, I mostly expect this to be of use when we explain how the query optimizer work. Of course, if you are investigating “why did you use this index and not that one” in production, this feature is going to be invaluable.

More posts in "RavenDB 4.1 Features" series:

  1. (04 Jul 2018) This document is included in your subscription
  2. (03 Jul 2018) Detailed query timing details
  3. (02 Jul 2018) Of course I know ya, dude
  4. (29 Jun 2018) Running RavenDB embedded
  5. (26 Jun 2018) Can you explain that choice?
  6. (20 Jun 2018) Cluster wide ACID transactions
  7. (19 Jun 2018) Explain that choice
  8. (22 May 2018) Highlighting
  9. (11 May 2018) Counting my counters
  10. (10 May 2018) JavaScript Indexes
  11. (04 May 2018) SQL Migration Wizard