Exploration
Within my application scenario, I have a specific screen that displays 8 different lists of items. Each list requires a separate query to Firestore, running asynchronously to retrieve documents from various collections. Through profiling the execution time of these 8 queries, I've observed a total wait time ranging from 3 to 6 seconds:
execution time: 5539.793ms
For every query, an average of 30 documents is being fetched. Below is a typical query structure:
const query = playersRef
.where("random", ">=", randomId)
.where("level", "==", currentUserLevel)
.where("location.country", "==", currentUserCountry)
.orderBy("random")
.limit(30);
Curiosity
I find myself in a state of confusion. While I understand that initiating 8 requests would lead to 8 round-trip times (RTTs), I am unsure whether the majority of time consumed is due to the physical distance to the data center or the complexity of the queries themselves, regardless of the distance (originating from Spain to Iowa).
Could consolidating all these queries into a single Cloud Function (deployed in Iowa and returning all data collectively) potentially diminish the overall execution time significantly?
I appreciate your insights on this matter.