Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizing Firestore Data Structure to Reduce Read counts #139

Open
2004yash opened this issue Dec 20, 2024 · 1 comment
Open

Optimizing Firestore Data Structure to Reduce Read counts #139

2004yash opened this issue Dec 20, 2024 · 1 comment
Assignees
Labels
Backend Backend issue using Typescript help wanted Extra attention is needed

Comments

@2004yash
Copy link
Contributor

image

Currently, each member's record is stored in an individual document within the Firestore collection. While this structure allows for easy querying of individual records, it leads to a significant spike in the number of reads. This is especially problematic when performing operations that require fetching data for all members, as it results in a separate read for each document.

The same issue exists for other collections where individual records are stored as separate documents.

Proposed Solution

To optimize Firestore's read costs and improve efficiency, we propose restructuring the data:

  1. Store all member records as an array within a single document.
  2. Apply this restructuring to other collections with similar issues.
  3. Implement pagination and partial document fetching (using Firestore's array-contains or similar features) to prevent fetching unnecessarily large data.

This approach will drastically reduce the number of reads, especially for bulk operations, while maintaining a manageable structure for the data.

@SkySingh04 SkySingh04 added Backend Backend issue using Typescript help wanted Extra attention is needed labels Dec 20, 2024
@govindup63
Copy link
Contributor

can you assign this issue to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Backend issue using Typescript help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants