3 ms·
I think a more useful example would be adding further information from the users profile to a leaderboard. That could be the name in a particular game or other
by ifcologne 11y ago
I think a more useful example would be adding further information from the users profile to a leaderboard.
That could be the name in a particular game or other data from the users profile. Or - limit the leaderboard by filtering on age, region or whatever.
- onion2k 11y agoAssuming they're unique you could do that just by using the username as the key to join the score table to the user table on. Everything would be the same as the example in the article, but without the join needed when you're just getting the names with their scores. Optimising a database for storage is really only a good idea when the additional redundant data is going to take up huge amounts of space. Storage is cheap. Making a query run faster isn't. Generally speaking you're better off optimising to reduce the number of joins and subqueries because they're the things that usually slow you down.
- lobster_johnson 11y agoThat would cause problems when users are renamed. You want foreign keys (which Arango doesn't have?) and transactions, and you also want to make sure that every name change updates all foreign tables. Changing it one place eliminates all possible mistakes, which is why surrogate keys were invented. The way I like to approach performance issues like these is to cache or precompute de normalized data as needed, and make sure the master data is as clean and normalized as possible. You could have a materialized view, or a trigger that produced the denormalized version, or just store the data is Memcached.