Pārlūkot izejas kodu

Add MongoDB Compact Example

Force MongoDB to release disk space from a collection after documents
have been deleted.
master
Nate Bohman pirms 4 gadiem
vecāks
revīzija
77408dc423
Parakstījis: Nate Bohman <natrinicle@gmail.com> GPG atslēgas ID: C10546A54ABA1CE5
1 mainītis faili ar 6 papildinājumiem un 0 dzēšanām
  1. +6
    -0
      python_utils/mongodb_compact.py

+ 6
- 0
python_utils/mongodb_compact.py Parādīt failu

@@ -0,0 +1,6 @@
from pymongo import MongoClient

mongo = MongoClient("mongodb+srv://admin:PASSWORD@staging.mongodb.staging.oonum.io/admin?ssl=false&retryWrites=true&serverSelectionTimeoutMS=5000&connectTimeoutMS=10000&authMechanism=SCRAM-SHA-256&w=majority")

# mongo["auth"].command({"compact": "Orgs", "force": True})
mongo["database"].command({"compact": "collection", "force": True}) # Mongo 4.4 can compact without blocking, older versions block IO during compaction.

Notiek ielāde…
Atcelt
Saglabāt