Saturday, 15 June 2013

mongodb - Using Mongo: should we create an index tailored to each type of high-volume query? -


We have two types of high-volume questions that look at documents related to a 5 characteristics: a date (LTE) Values ​​stored in an array, values ​​stored in another array, an integer (GT), and a float (GT).

In the second, these five characteristics include two more two.

Should we make two campus pointer, one for each query? Assume that each attribute has a high cardinality.

If we do, because every query contains many arrays, it does not seem that we can make pointer due to Mongo's restrictions.

Thank you!

The Index for the query after the first categories in the query significantly reduces the value of the additional index field < / P>

Conceptually, I find it best to think about fields other than sorting the small sub-tree index from the query. Before a large branch, the range chops, second small, third small etc. My general rule of thumb is only the first class of queries in the index.

Warning This rule is that additional fields in the index can be useful to assist in sorting the result back.

For the first query, I will create an index on two array values, and then the limitations are the most documents. As long as you can not close the range (LTE and GTE), there is no possibility of providing a high exclusion of the date field. It is difficult to tell without knowing the integer and the float domain.

If two additional properties of the second query also use categories in the query and do not have a significant high exclusion value, then I only work with one index.

Rob.

No comments:

Post a Comment