4 ms·
Assuming 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 th
by onion2k 12y ago
Assuming 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 12y 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.