H
H
Hash Hash2014-09-24 21:31:55
PostgreSQL
Hash Hash, 2014-09-24 21:31:55

Where is the best place to store user settings?

I have a Rails application with over 50 user options (timezone, privacy and display settings). Where is the best place to store them? In one table with basic user information or in a separate table? What is the best practice?
I am also considering placement in Postgres hstore.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vsuhachev, 2014-09-25
@Nith

If the settings are stored in the same table as the user and there are a lot of them, then this is an extra cost when swapping an object from the database in cases where the settings are not needed. For example, the user twitches each page in order to check his privileges, while in the load you also pull out 50 parameters and create objects for them.
Plus hstore and fields with json - no need to change the database schema when changing the composition of the parameters.
According to hstore: minus - binding to PG, plus - performance and they promise that in the next version they will add a full-fledged search and indexing by fields from hstore

P
Push Pull, 2014-09-25
@deadbyelpy

You probably won't have to search for users by certain fields in the settings.
In this case, you can create a table with a key - user id, and a parameter string in JSON format, then a simple solution, but there is nothing wrong with this approach.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question