I'm using Python (CPython 2.7.3 on Debian 7.8 amd64) with pymongo driver (version 2.7.2) to connect to a MongoDB (db version v2.4.12) database which has solely been used to store files in a GridFS storage collection. While mongodb can find the _id of a file object with a given filename instantaneously, requesting to delete that file given its _id takes an unusual 10s of seconds to complete during which mongod takes up 100% CPU time.

I'm not a mongodb expert and have not done any performance optimizations on it, but still I think there is something wrong here. What am I missing and how can I pinpoint and solve this problem?

I should add that there are millions of files in this collection with nearly 700GB size, and the free space left on disk is running very low.


> db.stats()
        "db" : "imagedb",
        "collections" : 6,
        "objects" : 80435832,
        "avgObjSize" : 6521.6805692766375,
        "dataSize" : 524576802628,
        "storageSize" : 563036266512,
        "numExtents" : 308,
        "indexes" : 7,
        "indexSize" : 6604172176,
        "fileSize" : 588057149440,
        "nsSizeMB" : 16,
        "dataFileVersion" : {
                "major" : 4,
                "minor" : 5
        "ok" : 1
  • Whats the size of the deleting object? – Antonios Jan 28 '15 at 13:45
  • files are quite small, average size 70KB, max 1MB – zaadeh Jan 31 '15 at 7:27
  • With so small size you don't actually need gridfs, can you share a db.stats() from the database that holds gridfs? – Antonios Jan 31 '15 at 13:27
  • @Antonis I edited the question. – zaadeh Feb 1 '15 at 17:51
  • Is there an index on chunks.files_id (there should be)? If yes try to make a search using that index and tell me how fast is it. I suspect that this index has become large and db needs time to access it. – Antonios Feb 2 '15 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.