Skip to content

Commit

Permalink
[improvement][mongodb cdc]optimize startup performance (apache#519)
Browse files Browse the repository at this point in the history
use 'collection.estimatedDocumentCount();' replace 'collection.countDocuments();'
  • Loading branch information
deng-jeffer authored Nov 26, 2024
1 parent 3ac63f2 commit ba0f97a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public List<SourceSchema> getSchemaList() throws Exception {
throw new IllegalStateException("No documents in collection to infer schema");
}

long totalDocuments = collection.countDocuments();
long totalDocuments = collection.estimatedDocumentCount();
long sampleSize = (long) Math.ceil(totalDocuments * samplePercent);
ArrayList<Document> documents = sampleData(collection, sampleSize);
MongoDBSchema mongoDBSchema =
Expand Down

0 comments on commit ba0f97a

Please sign in to comment.