Web Dev Cody
Web Dev Cody2y ago

question about convex bandwidth

will convex send over the entire database object if any property inside that entry has changed, or will it only send the updated fields? For example, if I have a table which stores a 2d array of 50x50 numbers, and I update a single number in that 2d array, will convex send the entire array to anyone doing a query for that data? If so, is there a better way I should setup my table to reduce bandwidth? like if I instead stored those 2500 items as separate DB entries and did a query for them, would convex only send over the single updated entry, or would my entire query re-run and fetch 2,500 items again?
4 Replies
jamwt
jamwt2y ago
(1) Yeah, the entire object gets shuttled to/from the database even if you change a single property if you keep it in a single document (2) mutations would be cheaper, but the first query would probably refetch everything. @sujayakar @rebecca might know for sure if documents coming out of the cache count as db bandwidth or not (n) in general, we've found people worry more about optimizing for db bandwidth too early and it's usually not a problem in practice. so I would start with whatever architecture is easier (one big document?) and see how things extrapolate after using the app for awhile. and please report back to us if you do this and you find a usage pattern (and architectural combination) that looks like it's going to blow through quota and be problematic! it's good for us to get this feedback
Web Dev Cody
Web Dev CodyOP2y ago
cool, I'll continue with my 2d array approach and let you know how my quote grows
jamwt
jamwt2y ago
yeah, sg. keep us in the loop
sujayakar
sujayakar2y ago
yeah, 2500 numbers at 8 bytes per number (float64) is 20KB per update which isn’t too bad! if the function result is cached, we won’t reexecute the query and charge database bandwidth as an optimization, note that database bandwidth gets rounded up to the nearest kilobyte, so storing, say a row per document would be a pretty efficient use of resources. i.e. 50 rows that contain an array of 50 numbers each. but as @jamwt points out, it’s probably not worth optimizing at the beginning.

Did you find this page helpful?