Docs Menu
Docs Home
/
MongoDB Manual
/ / /

flushRouterConfig

On this page

  • Definition
  • Compatibility
  • Syntax
flushRouterConfig

flushRouterConfig marks the cached routing table for a sharded cluster as stale, causing the next operation that requests the routing table to refresh the cache. Management of the routing table cache is handled automatically by the cluster.

Note

Running flushRouterConfig is no longer required after executing movePrimary, dropDatabase, or db.collection.getShardDistribution(). These commands now automatically refresh a sharded cluster's routing table as needed when run.

This command is available in deployments hosted in the following environments:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

Important

This command is not supported in serverless instances. For more information, see Unsupported Commands.

The flushRouterConfig is available on both mongos and mongod instances, and has the following syntax:

  • Flush the cache for a specified collection when passed in a collection namespace parameter:

    db.adminCommand(
    {
    flushRouterConfig: "<db.collection>"
    }
    )
  • Flush the cache for a specified database and all of its collections when passed in a database namespace parameter:

    db.adminCommand(
    {
    flushRouterConfig: "<db>"
    }
    )
  • Flush the cache for all databases and their collections when run without a parameter or passed in a non-string scalar value (e.g. 1):

    db.adminCommand("flushRouterConfig")
    db.adminCommand(
    {
    flushRouterConfig: 1
    }
    )

Back

enableSharding