previously i have tried this indexing order and mutikey false. i found 2 things
- The query still doesn’t work
- In the execution plan i still could see mutikey true, even when the created index is mutikey false
v: 2,
key: { merchantId: 1, discriminator: 1 },
name: 'mid_disc',
sparse: false,
unique: false,
firestoreOptions: { multikey: false }
},
db.Customer.find({
| merchantId: { $in: ["MER000023"] },
| discriminator: "customer"
| }).limit(8).hint("mid_disc").explain("executionStats")
{
ok: 1,
queryPlanner: { namespace: '' },
executionStats: {
nReturned: Long('8'),
requestPeakMemoryUsage: '4.00 KiB (4,096 B)',
dataBytesRead: '2.71 KiB (2,770 B)',
totalDocsExamined: Long('8'),
totalKeysExamined: Long('8'),
readUnits: Long('9'),
executionTimeMillis: Long('65'),
executionStages: {
stage: 'COMPUTE',
'$out1': 'toBson(map_set($record_1, "__id__", $__id___1, "__key__", unset))',
isQueryResult: true,
nReturned: Long('8'),
executionTimeMillisEstimate: Long('65'),
inputStage: {
stage: 'COMPUTE',
'$id1': '_id($__key___2)',
nReturned: Long('8'),
executionTimeMillisEstimate: Long('65'),
inputStage: {
stage: 'FETCH',
order: 'PRIMARY_KEY_ORDER',
source: '**/Customer',
inputRecordId: '$rid_2',
outputBindings: {
'$__key___2': 'row().__key__',
'$record_1': 'row[* - { __create_time__, __update_time__ }]()'
},
output: [ '$__key___2', '$record_1' ],
nReturned: Long('8'),
executionTimeMillisEstimate: Long('65'),
dataBytesRead: '2.02 KiB (2,066 B)',
inputStage: {
stage: 'LIMIT',
limit: Long('8'),
nReturned: Long('8'),
executionTimeMillisEstimate: Long('63'),
inputStage: {
stage: 'IDXSCAN',
fields: [ null, null, '$rid_2' ],
index: '**/Customer (merchantId ASC, discriminator ASC)@[id = CICAgLiI_5oK, isMultikeyIndex = true, multikeyPaths = {merchantId=[merchantId], discriminator=[]}]',
ranges: '/\n|----["MER000023"]\n |----["customer"]\n',
nReturned: Long('8'),
executionTimeMillisEstimate: Long('63'),
docsExamined: Long('8'),
dataBytesRead: '704 B'
}
}
}
}
}
}
}
db.Customer.aggregate([ { $match: { merchantId: { $in: ["MER000023"] }, discriminator: "customer" } }, { $group: { _id: 1, n: { $sum: 1 } } } ])
Uncaught:
MongoServerError[InvalidArgument]: The query failed since it attempted to use 128.00 MiB (134,221,824 B) when the limit is 128.00 MiB (134,217,728 B).