Optimize Query Performance
Posted lixingyang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Optimize Query Performance相关的知识,希望对你有一定的参考价值。
Create Indexes to Support Queries
For commonly issued queries, create indexes. If a query searches multiple fields, create a compound index. Scanning an index is much faster than scanning a collection. The indexes structures are smaller than the documents reference, and store references in order.
Example
If you have a posts
collection containing blog posts, and if you regularly issue a query that sorts on the author_name
field, then you can optimize the query by creating an index on the author_name
field:
db.posts.createIndex( { author_name : 1 } )
Indexes also improve efficiency on queries that routinely sort on a given field.
Example
If you regularly issue a query that sorts on the timestamp
field, then you can optimize the query by creating an index on the timestamp
field:
Creating this index:
db.posts.createIndex( { timestamp : 1 } )
Optimizes this query:
db.posts.find().sort( { timestamp : -1 } )
Because MongoDB can read indexes in both ascending and descending order, the direction of a single-key index does not matter.
Indexes support queries, update operations, and some phases of the aggregation pipeline.
Index keys that are of the BinData
type are more efficiently stored in the index if:
- the binary subtype value is in the range of 0-7 or 128-135, and
- the length of the byte array is: 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, or 32.
以上是关于Optimize Query Performance的主要内容,如果未能解决你的问题,请参考以下文章
问题解决:信息提示SpringBoot启动时提示The APR based Apache Tomcat Native library which allows optimal performanc(代
文献阅读:ESAM: Discriminative Domain Adaptation with Non-Displayed Items to Improve Long-Tail Performanc
CMU Advanced DB System - Query Optimizer Implementation
scipy.optimize.fmin和scipy.optimize.minimize之间的区别
当 scipy.optimize.minimize 可能用于相同的事情时,为啥 scipy.optimize.least_squares 存在?