3 Replies Latest reply on Oct 27, 2016 2:07 AM by hchiorean

    ModeShape with MongoDb performance

    eugeney

      Hello
      I tested ModeShape with configure storing Binary Values in MongoDB and found problem with performance.

      The class MongodbBinaryStore calls db.collectionExists(..) method. But db.collectionExists method realization is very worse it call getCollectionNames() and iterate through all elements.

      From my point of view, the method listCollectionNames() from MongoDatabase with filter should be used.

       

      mongoDatabase.listCollections().filter(new Document("name", collectionName)).isEmpty()

        • 1. Re: ModeShape with MongoDb performance
          hchiorean

          ModeShape only interacts with the Mongo Java Driver (the db.collectionExists is a driver method). Looking at the latest driver code (mongo-java-driver/DB.java at master · mongodb/mongo-java-driver · GitHub ) the implementation for this particular method is pretty much the same as in the version that ModeShape uses, meaning it hasn't been reported (yet) as a performance issue.

           

          If this were a performance issue, I would expect the driver folks to fix it - perhaps you can take this issue up with them.

           

          Regarding your proposed alternative: mongoDatabase.listCollections().filter(new Document("name", collectionName)).isEmpty() - I don't see these APIs anywhere in the driver so I'm not sure how the ModeShape code could be changed to use this approach (the driver version used by ModeShape is 2.14.0)

          • 2. Re: ModeShape with MongoDb performance
            eugeney

            Thanks for your answer.

            Since, Mongo Java Driver 3.0 the method getDB from MongoClient is deprecated. New MongoData instance returned by getDatabase method should be used. So, new code mongoDatabase.listCollections().filter(new Document("name", collectionName)).first()!=null can be used.

            I'm using Mongo Java Driver 3.3.0

             

            Thanks.

            • 3. Re: ModeShape with MongoDb performance
              hchiorean

              Ok, so this would mean we'd have to change the driver version we're using and migrate from 2.x to 3.x. It's something which we can investigate for 5.3, so feel free to log an enhancement JIRA for this. Thanks.