Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda