Firebase updateDoc simple query taking 2000ms

Viewed 24

I have a simple schema:

await addDoc(likesRef, {
            user: user.uid,
            post: id,
            active: true
        })

So my problem is that, when I want to update from active true to active false for example, it is taking 2000ms.

            const likeDoc = doc(db, 'likes', document.docs[0].id)

enter image description here enter image description here

I have only like 3 documents on the collection, in the screenshot it says 1300ms but usually takes 2000ms to execute.

If i run the update some times in a row, it returns in 200ms all queries (I think because it is caching). But If i do nothing in 2 minutes, then I try to update, it always take around 2000ms.

Why is it taking so long so run a simple query?

const handleLike = async () => {
    console.time()
    const docRef = doc(db, 'likes', 'ZZFrJPcbVfFo9rZareeY')
    await updateDoc(docRef, {
        active: false,
    })
    console.timeEnd()
}

takes 1300ms.

0 Answers
Related