Reputation: 3065
As you may see in my question history I am struggling to use MongoDB. I have the following document structure.
The value of t can be the same across many documents and the value of vdata.d
will also repeat itself many times but never for the same value of t
.
I have placed indexes on t
and vdata.d
.
The t
value may be repeated in excess of 10,000 times and there are 355.9m documents in total.
I am really struggling to query the data. How do I query the data for a value of t
for a given value of vdata.d
. I have the following and nothing is returned even though I know there is an entry for it.
db.TagValues.aggregate({$match: {t: "99CalcTrigger"}}, {$match: {"vdata.d: "2018-12-09T04:40:00Z"}
Also if I just query the data using:
db.TagValues.find({ "vdata":{"d": new Date ("2018-12-09T04:40:00Z")}})
Again nothing is returned and also the query is very very slow.
I have been reading the MongoDB documentation for hours but I am not making any progress.
Upvotes: 0
Views: 41
Reputation: 230326
Use dot notation
db.TagValues.find({"t": ..., "vdata.d": ...})
and also the query is very very slow
Of course, you're not passing t
there, in addition to not using index on vdata.d
. So mongod does full collection scan.
Upvotes: 1