Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
Creating a sample of huge collection in mongodb to test queries

I have a huge collection of tweets downloaded by someone else and I want to test an aggregate() query on that. But, it takes a lot of time to execute and I want to quickly check my results.

Can I create a smaller sample collection using the huge original collection so that I can test new queries on that quickly? If yes, how can I do that? If no, how do people usually test the correctness of the query before execution?

All the answers I found till now say about dumping the entire collection while I just want a sample of it to run my aggregate() query. I've tried doing a db.collection.findOne().aggregate(/*QUERY*/) but it throws an error saying that aggregate is not a function

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

you can easily create a subset of your collection like this :

db.collection.aggregate({$limit: 1000}, {$out: "subsetCollection"})

this will take 1000 results from yout original collection and write the to a new collection named "subsetCollection". You can then test your aggregation queries on this new collection

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!