[Reading Notes] The Definitive Guide to MongoDB

    Be sure to avoid "$where" queries unless absolutely necessary, as they are much slower than regular queries. Each document is converted from BSON to a JavaScript object and then run through the "$where" expression. Also, indexes cannot be used. So consider the usage of "$where" when you are desperate.

    Use regular queries as prefilters, combined with "$where" without sacrificing performance. If possible, use an index to filter based on non-"$where" clauses, "$where" is only used to tune the results.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326646214&siteId=291194637