Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ Effect MongoDB plan cache     - The file name is garbled or deleted files with special characters under Linux (Linux)

- Development environment to build MEAN In Ubuntu 15.10 (Server)

- Use mysqldump backup performed MariaDB (Database)

- Free compiler install MySQL-5.6.14 (Database)

- Android custom controls create the simplest skid menu in the history (Programming)

- KVM add virtual disks (Linux)

- CentOS 6.4 RPM install MySQL-5.6.22-1 (Database)

- Linux system versions organize local root password cracking method (Linux)

- Linux system package manager -RPM (Linux)

- Linux bash: scp: command not found the problem (Linux)

- Linux system started to learn: how to view the contents of the seed on the Linux file (Linux)

- How to make GRub instead of the default Ubuntu software center (Linux)

- To disable the function by pressing Ctrl-Alt-Del to restart the system in RHEL / CentOS 5/6 (Linux)

- MySQL Parameter Tuning Best Practices (Database)

- Experience CoreCLR stack unwinding characteristics of initial implementation on Linux / Mac (Linux)

- Android child thread really do not update UI (Programming)

- Linux file content inspection - cat, tac, no, more, less, head, tail, od (Linux)

- Nginx Beginner Guide (Server)

- Use XtraBackup be physical standby database MySQL (Database)

- Analysis of common mistakes when compiling MySQL installation (Database)

 
         
  Effect MongoDB plan cache
     
  Add Date : 2018-11-21      
         
         
         
  After MongoDB 2.6 Primary replication set to create the index, we found Secondary query did not take the latest index.

After a temporary plan to clean out the cache set correctly. When I observed performance problems, the statement did not take optimal execution plan.

For MongoDB 3.0.3 and earlier versions, it can be solved by the following two methods:
1. explicitly specify hints for queries.
2. Set the query plan cache index filter to override the default query plan.

Fixed in version 3.0.4.

SERVER-15225, SERVER-20139
https://jira.mongodb.org/browse/SERVER-15225

    Execution plan cache refresh problems, the same kind of query execution plan cache does not have to verify, but the same kind of query conditions are different possible implementation is different.

    You can set parameters to resolve internalQueryCacheReplanningEnabled
    The query optimizer caches plans for each query shape and reuses these plans for a time. In situations where the performance of the cached plan is poor for a particular instance of the query shape, the optimizer may select a the plan with poor performance and fail to evict the cache entry. This behavior may impact deployments where two queries with the same shape have different performance characteristics if they have different selectivity.
    This improvement makes the query planner evaluate the cost of the cached query plan, and if the cost of this plan is too high, the query planner switches to a more efficient plan. This more efficient plan is then cached for future use.
    This improvement is not enabled by default. To enable by default set the internalQueryCacheReplanningEnabled parameter totrue using the setParameter command on a running system, or at start time using the setParameter commandline option orsetParameter in the configuration file.
    For example, to enable using setParameter:
    db.runCommand ({setParameter: 1, internalQueryCacheReplanningEnabled: true})
    This improvement can be disabled as follows:
    db.runCommand ({setParameter: 1, internalQueryCacheReplanningEnabled: false})
    3.0.4 can use this parameter, the default is off

Query plan

In the case of a given available indexes, MongoDB query optimizer processes the query and select the most efficient in terms of queries against a query plan. Every time when the query is executed, the query system will use the query plan.

The query optimizer only for those who have multiple query plan looks feasible plan cache.

When the contents of the collection is changed, the query optimizer will re-evaluate the query plan to ensure optimal query plan. You can specify index optimizer evaluation index by using a filter.

For a given query, you can use the explain () method to view the statistics of the query plan.

Query plan amendments

With the collection of change over time, in one of the following several cases, the query optimizer will remove the query plan and be re-evaluated:
    1. The collection of 1,000 receiving write operation.
    2. The reIndex rebuilds the index.
    3. You add or delete an index.
    4. The mongod process restarts.

Cached query plan Interface

2.6 new feature

MongoDB provides a query plan cache commands and ways to view and modify the query plan has been cached.

db.runCommand ({planCacheListFilters: Product})
db.runCommand (
  {
      planCacheListPlans: "Product",
      query: {Path: / ^ 9-1-6 (- \ d +) * $ /, "Status": {$ lt: 4}}
  }
)
db.runCommand (
  {
      planCacheClear: "Product",
      query: {Path: / ^ 9-1-6 (- \ d +) * $ /, "Status": {$ lt: 4}}
  }
)
db.runCommand (
  {
      planCacheClear: "Product"
  }
)

Index Filter

2.6 new feature.

Index filter optimizer decide which index to assess as a query shape. Shape a query by the query, sorting and mapping described composition. If a given query filter shape there is an index, the optimizer will only consider the filter specified in these indexes.

When there is an index filter query shape when, MongoDB will ignore the hint (). If you want to know whether a MongoDB query using the index filter, you can check explain.filterSet field explain () output.

Index filter will only affect the assessment index optimizer, the optimizer may still choose to scan the collection as a given query shape winning program.

Index filter exists only in the server process, after the shut down and will not be saved. MongoDB also provides a command to manually remove the filter.

Since the index filters to rewrite the optimizer and hint () method of the expected action, the rational use of the index filter.

db.runCommand (
  {
      planCacheSetFilter: "orders",
      query: {item: "ABC"},
      projection: {quantity: 1, _id: 0},
      sort: {order_date: 1},
      indexes: [
        {Item: 1, order_date: 1, quantity: 1}
      ]
  }
)
     
         
         
         
  More:      
 
- mysql_config_editor encryption and decryption of the new features of MySQL realization (Database)
- How to protect your eyes automatically adjust the screen brightness on Linux (Linux)
- Lua study notes under ubuntu (Linux)
- Android Studio simple setup (Linux)
- Debian 8 (amd64) installation deployment Memcached management tools MemAdmin (Server)
- Fedora10 use Git version Configuration Management (Linux)
- MySQL stored procedures and triggers (Database)
- How to install Ubuntu applications Device 7 (Linux)
- Java, extends and implements Usage (Programming)
- How to use the DM-Crypt encryption Linux File System (Linux)
- Ubuntu install the camera driver (Linux)
- Through Oracle to help restore MySQL data problems (Database)
- Seven Steps to Help Google Chrome Speed - (Linux)
- dd command: do hard disk IO performance test (Linux)
- Make command Detailed Tutorial (Programming)
- LinkedList Basic Usage (Programming)
- File sharing and fork function (Programming)
- Java how to achieve bubble sort the problem Arraylist (Programming)
- Adding SSH to Github (Linux)
- Installation Experience open source car Automotive Grade Linux system (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.