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

155
Views
I have more than 50,000 documents in my firestore and it is taking more than 30secs to sort and find in limits of 50. how to speedup?

Here is my snipping code of React Native which I am using for my mobile application. Please help me with this can't wait 30sec for just 50k data. imagine the time it will take to load in 500k of data or more

useEffect(() => {
    const fetchData = () => {
      setLoading(true);
        firestore().collection('FData')
            .orderBy('counter', 'desc') //order using firestore counter
            .limit(50) //limiting value
            .onSnapshot(snapshot => { 
                var items = [];
                snapshot.forEach((doc)=> {
                    items.push({ id: doc.id, ...doc.data() });
                });
                setLoading(false);
                setList(items);
            })
    };
    fetchData();
}, []);

i have tried shifting the position of counter to the top but its also not working

almost 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can try to sort them in the app. But I think your main problem - you trying to get 50k items by ONE request. It's to much. 10 item it's ok. More than 100 - it's not ok.

almost 4 years ago · Santiago Trujillo Report

0

Please help me with this can't wait 30sec for just 50k data.

Reading 50k documents, it's way too much data to read in a single go. Bear in mind that, that the query performance in Firestore depends on the number of documents you request and not on the number of documents you search. So it doesn't really matter if you search for 10 documents in a collection of 100 documents or in a collection that contains 100 MIL documents, the response time will always be the same. So to be able to read data fast, I recommend you load it in smaller chunks. This practice is called pagination and it can be really simple implemented using query cursors if take a look at the official documentation.

Besides that, since everything in Firestore it's about the number of reads you perform, reading 50k documents at once, can be a bit expensive.

almost 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!