DB storage question
Hey! I am looking at storing a GPS path that is updated at a set interval, every X points I want to update the DB record. I'm trying to understand the best way to store this. Currently I have a table that shows the Activity: id | coordinates | date and had been updating the coordinates for testing and it worked fine.
In the docs there was a part about trying to limit array size to 5-10 but my approach would probably end up 500-1000 array size
https://docs.convex.dev/database/document-ids#trading-off-deeply-nested-documents-vs-relationships
Is this recommendation more so if i need to query the data vs storage safety? Otherwise are there any negatives to storing the gps points in a Coordinates table with a reference to the ActivityId for indexing / retrieval ?
Document IDs | Convex Developer Hub
Create complex, relational data models using IDs.
3 Replies
There’s a hard limit of 1024 elements in an array. I would store every X points in a new record and fetch all the records when you want to get the full list. This would also let you fetch the most recent parts of the path without fetching it all. If you’re unsure about how to structure it in the schema or query for it, lmk. I have a draft of a post on db relationships I can run by you
There’s also a 1MB limit on a document. If you don’t think you’d run over that limit, you could also store each batch of points as an array within an array, so you have a shorter top level list. It’s not the best from a db architecture pov, but could be a tactical solution
sure, the post could be useful if you dont mind sharing
so a table that references the activity broken up into X points could work fine for sure