Search code examples
mongooseamazon-dynamodbquery-optimizationdatabase-performancedynamodb-queries

Are Mongoose arbitrary queries as slow compared to DynamoDB Scan?


I am reading in this blog: DynamoDB is bad for analytics. It is true that because you cannot run arbitrary queries against DynamoDB tables (technically speaking you can but it's extremely inefficient due to Scan nature), you cannot perform ad-hoc reports of your data

So I am wondering that if Mongo does sort/order those things in a better way so that running something like this doesnt need to scan the entire collection

Person.
  find({
    occupation: "student",
    age: { $gt: 17, $lt: 66 }
  }).
  sort({ occupation: -1 }).
  select({ name: 1, occupation: 1 }).
  exec(callback);

Solution

  • for performance. you need to try proper indexing in the database. it's making a big effect on data queries. for further information, you can review this main source site. Query-Plan-in-mongo