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
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.Hard to say. Early days on the app and usage patterns haven't been established.
Good point. Storing
userId
and clientId
separately allows for indexing on userId
, which should help with query performance as the dataset grows.Presumably for operations on single records (like delete) it will be better to use the convex
_id
where possible?Yes