Auth0 Home Blog Docs

Best user identifier to use to store in local database



This question was already asked here here, but the answer wasn’t entirely satisfactory.

This documentation claims that user_id is the best field to use as the unique identifier, but the problem with that field is that it has an undefined length due to the variable length of any identity provider/connection name. This implies that the only appropriate SQL data-type for user_id would be TEXT which cannot be indexed. Does the raw pre-concatenated id field have a set/maximum length? As in, if I limit the identity providers to only “Auth0” (5 characters), is the character length of user_id known (so I can use an index-able data-type like VARCHAR[length] instead of TEXT)?


@chrissslee93 you can always track your own key. It isn’t common for customers to store their own unique identifier on the user’s app_metadata field. This would allow you to control the data type. Besides using user_id or this approach I don’t see another option.