arrays


MongoDB index on a key/value document in an array in a document in an array always scans all documents


I am doing a proof of concept with MongoDB. I have a document that has a complex structure. I am able to easily search on it, but the search is becoming slow. I am wondering if I can build any index on my collection. The real object is more complex, but this is the minimal example that shows the problem. The data is not real, I just generated a million documents with some values set from a counter.
> db.records.findOne()
{
"_id" : ObjectId("591a92bd330f72395c3ecb9c"),
"recordId" : "T1-C450",
"episode" : [
{
"episodeDate" : NumberLong("1494913725568"),
"data" : [
{
"key" : "sequence",
"value" : "A450"
},
{
"key" : "alternativeSequence",
"value" : "X450"
}
]
},
{
"episodeDate" : NumberLong("1494913725568"),
"data" : [
{
"key" : "sequence",
"value" : "B450"
},
{
"key" : "alternativeSequence",
"value" : "Y450"
}
]
}
]
}
I am searching documents by:
> db.records.find({"episode.data.key":"sequence", "episode.data.value":"B450"})
I have tried the following index that is used for the search above:
> db.records.createIndex({"episode.data.key":1, "episode.data.value":1})
However when I run explain query:
> db.records.find({"episode.data.key":"sequence", "episode.data.value":"B450"}).explain('executionStats')
...it seems like the index returns everything.
"stage" : "IXSCAN",
"nReturned" : 1000000,
And the total time to run the query is longer than when the index is not used.
Is there any better way of indexing the key-value pairs in the nested array as in the example above? Is it possible?

Related Links

Classic ASP - combining two lists/arrays
How to pass multiple Highcharts parameters in JSON array
traversing tables with selenium/webdriverjs
Printing cell array
Print a 5by5 matrix in MIPS using 1 dimensional array
Running Time of built in functions
Sum of matrices in 3-dimensional object of variable dimesions without looping
Quickly select arrays which have at least k elements common with master array
In Swift, how efficient is it to append an array?
How to correctly split a signal in matlab?
Accessing array of numbers in ARM (with Komodo compilation)
Load, show, convert image from byte array (database) in Windows Phone 8.1
Assembly - Copying an array of bytes - MIPS
Deep Query using MongoDB
plot array from matrix matlab [closed]
Function similar to head() in Matlab

Categories

HOME
security
project-management
oauth
jasmine
formal-verification
rebol
ext.net
tizen-wearable-sdk
spring-cloud-contract
proguard
requirejs
android-viewpager
eclipse-cdt
wicket
iso
webmethods
sign
multiple-monitors
zope
factor-analysis
jpeg2000
chocolatey
eclipselink
attask
ios10.3
ip-camera
multicore
jni
apply
jquery-form-validator
dspic
memsql
iis-10
badge
samsung-mobile
pipelinedb
rhandsontable
excel-2013
owl-api
invoke-command
vegan
encase
pdflatex
swiftcharts
von-neumann
viewstate
nunit-3.0
pace
rider
duktape
concrete5-5.7
stress-testing
amd
filepath
sgmlreader
livescribe
multi-agent
bnd
maintenance
slidesjs
ruby-on-rails-2
android-bitmap
mcrypt
static-code-analysis
unity3d-editor
emgu
barcode-printing
ebtables
hspec
uistackview
debugdiag
rstudio-server
aescryptoserviceprovider
cron-task
visible
gradle-eclipse
shipitjs
dac
asp.net-mvc-partialview
financial
mfc-feature-pack
sourcegear-vault
p-np
sem
httpie
multipleselection
tilestache
moai
cpu-speed
kendo-mvvm
author
humanizer
ember-addon
factors
lov
gfs
java.util.date
bigint
trimming
threadx
multiple-conditions
cgimageref
fileconveyor
arbor.js
xgettext
feof
tfs-power-tools
subtract
getstring
file-exists
text-services-framework
quick-search
revert
gwt-2.2-celltable
aio
code-design
web-statistics
usability-testing
microsoft.ink
hmacsha1
dirty-data
data-execution-prevention
hardware-infrastructure
rd

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App