3

In order to improve write performance, a lazy indexing strategy can be used. From what I understand, this essentially means that the index propagation is eventually consistent after the write (as opposed to the Consistent mode, where the write will only complete once the index update has also completed).

Lazy index on MSDN:

To allow maximum document ingestion throughput, a DocumentDB collection can be configured with lazy consistency; meaning queries are eventually consistent. The index is updated asynchronously when a DocumentDB collection is quiescent i.e. when the collection’s throughput capacity is not fully utilized to serve user requests. For "ingest now, query later" workloads requiring unhindered document ingestion, "lazy" indexing mode may be suitable.

Question:

If a document is queried for (let's say by id) BEFORE the index has updated (it is still lazily propagating), will the document not be found OR will there be some form of "table scan" and the document returned with sacrifice in RU (and performance)?

EDIT: The above is assuming Session Consistency on the database.

Dave New
  • 38,496
  • 59
  • 215
  • 394

1 Answers1

2

Queries that use the "id" and "_rid" properties do not depend on the indexing policy and are always updated consistently. i.e. same as the configured consistency level of the account (in your case, session consistency).

Queries using "id" are always served from the index, are a seek, not a scan.

Aravind Krishna R.
  • 7,885
  • 27
  • 37
  • So, querying for a document by something other than Id before the index has updated would be eventually consistent with lazy indexing. I.e. The document won't be found until the index has finished updating. But, if queried by Id it would be session consistent (or whatever the database is configured with)? – Dave New Nov 30 '15 at 19:22
  • Yes, that's correct. In practical terms, lazy indexing is near real-time if you're not using the full throughput capacity of the collection. – Aravind Krishna R. Dec 01 '15 at 17:23