Back

[SOLVED] Performance / Security best practice for storing user data.

  • 0
  • Users
  • Accounts
punti_z
23 Oct, 2023, 14:37

On user account creation I save certain attributes of user data that I query as and when required. Just want to ask, from a performance and security standpoint, what's the difference if I store said information in users Auth Prefs or a separate DB collection ?

Any specific speed, performance or security related differences or either way is more of less exactly the same just DB will provide more fine grain quering ?

TL;DR
The user is asking for advice on the best practice for storing user data in terms of performance and security. The suggestions are to either use user Auth Prefs or a separate DB collection. It is recommended to use a separate DB collection if the user preferences need to be frequently changed and queried. However, if the preferences don't need to be changed often and the goal is to simplify the experience, then using user Auth Prefs could be a good option. The main concern is performance and load on the DB, so it is important to consider the intended usage and whether fine-grained querying is necessary.
Aditya Oberai
23 Oct, 2023, 14:58

@punti_z the DB would allow for easier querying (user prefs aren't queryable by default)

I'd want to raise a question on what the intended usage is, to help clarify which of the two are better fit for your purpose

Guille
23 Oct, 2023, 15:01

Complementing what @Aditya Oberai said, user preferences can be edited by the user, if you don't want that behavior, a collection will be better as you'll have more control

punti_z
23 Oct, 2023, 15:26

Things like user app preferences i.e., dark/light mode, that would be queried everytime user opens the app to ensure they synced across devices. My concern specifically was more around performance and load on the DB, but the more I think about it since both will use database to store and retrieve information, assuming high traffic performance either way should be the same in which case in would prefer the database.

Aditya Oberai
23 Oct, 2023, 15:44

You'd need to make a call in either case

The idea with the separate user prefs endpoint was to simplify the experience, especially for attributes that don't need to be changed too often, so you call them once and maintain state.

In your case, the DB might provide you with more flexibility, especially if you expect these to change frequently and need to query often.

punti_z
23 Oct, 2023, 15:49

Thanks

punti_z
23 Oct, 2023, 15:49

[SOLVED] Performance / Security best practice for storing user data.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more