[DOCS-15245] [Server] Multikey Index Page Example Issue Created: 14/Apr/22 Updated: 30/Oct/23 Resolved: 17/Jul/23 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual |
| Affects Version/s: | None |
| Fix Version/s: | Server_Docs_20231030 |
| Type: | Task | Priority: | Minor - P4 |
| Reporter: | Ronan Merrick | Assignee: | Kanchana Sekhar |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | bugfix, docs-onboarding-candidate, quick-win, server-docs-bug-bash | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Participants: | |
| Days since reply: | 30 weeks ago |
| Story Points: | 3 |
| Description |
|
On the Multikey Index page, at the bottom of the page we provide an example of using an index to support sort operations on a field containing an array of documents. For the inventory, collection we suggest the following index:
Further down the page then we say:
One of these is:
However this doesn't meet one of the restrictions for using an index to sort a multikey field:
If you run the query using the data and index from the page and perform explain, there is a blocking SORT:
This is discussed on I believe that we should remove this example as it cannot use an index to SORT. |
| Comments |
| Comment by Kanchana Sekhar [ 12/Jul/23 ] |
|
PR: https://github.com/10gen/docs-mongodb-internal/pull/3726 |
| Comment by Juan Ley [ 07/Jul/23 ] |
|
I found the answer in the documentation https://www.mongodb.com/docs/v4.4/core/index-multikey/: This is the sort behavior: The index boundaries for all sort fields are [MinKey, MaxKey], and Query 1 does not have min/Max keys {db.test.find( ).sort( { "stock.size": 1, "stock.quantity": 1 } )} and therefore no blocking sort. ).sort( { "stock.quantity": 1 })} and therefore it has a blocking sort. |
| Comment by Juan Ley [ 29/Jun/23 ] |
|
Yes the documentation: https://www.mongodb.com/docs/manual/core/index-multikey/ has a mistake in the last example. Explain plan of Query with the data shows: db.test.find( { "stock.size": "M" }).sort( { "stock.quantity": 1 } ).explain("allPlansExecution") }, , , , } This shows a SORT Stage |