jedahu
jedahu4mo ago

My app needs client generated ids. To

My app needs client generated ids. To prevent between-user clashes I need to either generate an id like <user-id>-<uuid> or have the db record store the user id as well as the generated id. In the first case the index part of the query would be q.eq('clientId', '<user-id>-<uuid>'), and in the second q.eq('userId', '<user-id>').eq('clientId', '<uuid>'). Are there any significant performance considerations either way?
5 Replies
Hmza
Hmza4mo ago
q.eq('userId', '<user-id>').eq('clientId', '<uuid>') is faster read then this <user-id>-<uuid> significance of performance would depend on how much data is there.
jedahu
jedahuOP4mo ago
Hard to say. Early days on the app and usage patterns haven't been established.
Hmza
Hmza4mo ago
Good point. Storing userId and clientId separately allows for indexing on userId, which should help with query performance as the dataset grows.
jedahu
jedahuOP4mo ago
Presumably for operations on single records (like delete) it will be better to use the convex _id where possible?
Hmza
Hmza4mo ago
Yes

Did you find this page helpful?