問題タブ [compound-index]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
mongodb - _rperm の解析でのインデックス作成メソッド
_rperm
Parse インデックスが Mongo でどのように機能するかを理解しようとしているときに、定義したインデックスでフィールドを指定していないにもかかわらず、遅いクエリの一部が (ACL からの) フィールドを使用していることに気付きました。_rperm
すべてのクエリにあるわけではないので、インデックスを作成する必要があるクエリとそうでないクエリがあるのはなぜだろうと思っています。
IDだけでクエリを実行すると、
すでに定義されているインデックス{"_id": 1, "_rperm": 1}
だけでなく、インデックスが必要なようです。{"_id": 1}
parse はバックグラウンドで何を追加_rperm
して、いつインデックスとして含める必要がありますか?
mongodb - Custom MongoDB Object _id vs Compound index
So I need to create a lookup collection in MongoDB to verify uniqueness. The requirement is to check if the same 2 values are being repeated or not. In SQL, I would something like this
If the above query returns a count then it means the combination is not unique. I have 2 solutions in mind but I am not sure which one is more scalable. There are 30M+ docs against which I need to create this mapping.
Solution1:
I create a collection of docs with compound index on key1 and key2
Solution2:
I write application logic to create custom _id by concatenating value1 and value2
Personally, I feel the second one is more optimised as it only has a single index and the size of doc is also smaller. But I am not sure if it is a good practice to create my own _id indexes as they may not be completely random. What do you think?
Thanks in advance.
Update:
My database already has a lot of indexes which take up memory so I want to keep index size to as low as possible specially for collections which are only used to verify uniqueness.
mongodb - mongodb の複合インデックス構文
複合インデックスの定義方法に関する簡単な質問
定義に従って、以下のように複合インデックスを作成できます。これにより、 and の複合インデックスが作成されstudent_id
ますclass_id
。
しかし、私がこのようなものを与えるとどうなりますか
構文は有効で、インデックスを受け入れますが、インデックスがどのように作成されるかわかりません。
何かご意見は ?
mongodb - MongoDB は、複合インデックスの一意性制約を考慮していないようです
約 5 億のドキュメントを含むコレクションがありますが、これらの特定のサブセットに一意性制約が適用されていないようです。一意性制約は、複合インデックスに適用されます。
このコレクションのインデックス:
次のクエリを実行すると、クエリがインデックス 'sessionId_1_modelFolder_1_modelName_1' の複合インデックス フィールドで一致しているにもかかわらず、重複が発生します (IP の問題により、特定のフィールド値が編集されています)。
出力のサブセット:
このドキュメントのサブセットのバッチ挿入を強制終了し、後でそれらを再一括挿入しましたが、これにより何らかの形で重複が可能になることに驚いています。私は夢中になっていますか、それとも特定の条件下で可能ですか?