r/DatabaseHelp • • Aug 01 '17

Table structure and optimize query question

Hi guys, I have been messing around with SQL on sqlfiddle http://sqlfiddle.com/#!9/c00a46/1

If you take a look at that link, I have settings and user_settings. Settings holds all default values and user_settings holds any settings changed from default set by a user.

What I planned on doing is writing a script that checks to see if user_settings key is null if it is it applies the default value. My question is, should I query settings, save that into say... Redis, and then update the default values periodically or should I get the default values every time I look up a user? Grant it because this is built as a property bag that might have third party software the user_settings could change on a whim.

Ideas? Comments?

1 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/Javlin Aug 01 '17

Would you suggest something different if the settings became larger? For example say it grew to a few thousand rows.

1

u/wolf2600 Aug 02 '17

Would every setting apply to every user? If so, then I think the query I posted above would probably be best (except maybe apply the userid/key filters as the join condition rather than as a WHERE clause.)