[SERVER-26921] Parallel array check in key generation is inconsistent with multikey definition Created: 05/Nov/16  Updated: 27/Jan/17  Resolved: 27/Jan/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Naresh Muddakkagari Assignee: David Storch
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-5580 covered indexes are improperly applie... Closed
Operating System: ALL
Sprint: Query 2017-02-13
Participants:

 Description   

db.mk.insertOne({"i":12, "j":17})
db.mk.createIndex({"i":1, "j":1})

on winningPlan "isMultiKey" : false.

when i insert single element array still the multikey is false

db.mk.insertOne({"i":12, "j":[17]})

on winningPlan "isMultiKey" : false.

in contrast

db.mk.insertOne({"i":[12], "j":[17,21,24,27]})

is not allowed though i is a single element array!



 Comments   
Comment by David Storch [ 27/Jan/17 ]

Hi mnareshy,

In commit c7c8e4151d under SERVER-5580 we changed the definition of a multikey path from "a path that has an array with more than one element" to "a path that has an array along it". This means that indexes over single-element arrays or empty arrays are now considered multikey. For example:

> db.mk.createIndex({"i":1, "j":1});
> db.mk.insertOne({"i":12, "j":[17]});
> db.mk.find().hint({i: 1, j: 1}).explain();
{
    ...
		"winningPlan" : {
			"stage" : "FETCH",
			"inputStage" : {
				"stage" : "IXSCAN",
				"keyPattern" : {
					"i" : 1,
					"j" : 1
				},
				"indexName" : "i_1_j_1",
				"isMultiKey" : true,
				"multiKeyPaths" : {
					"i" : [ ],
					"j" : [
						"j"
					]
				},
    ...
}

You can see from the explain that the index {i: 1, j: 1} is considered multikey due to field j being tracked as a multikey path. The only indexed array contains a single-element, so this demonstrates that single-element indexed arrays are now considered multikey.

Since the definition of multikey is now consistent with the parallel array check, I'm resolving this ticket as a duplicate of SERVER-5580. Please let me know if you have any questions or concerns.

Best,
Dave

Comment by Kelsey Schubert [ 08/Nov/16 ]

Hi mnareshy,

Thank you for the detailed description of this behavior. I've assigned this ticket to the Query Team for further investigation. Please continue to watch for updates.

Kind regards,
Thomas

Generated at Thu Feb 08 04:13:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.