Yeah, you want an index on associated_entity. You probably also want an index on type, and on related_entity in Names. Indexes speed up searches against that column at the cost of slowing down INSERT and UPDATE operations; usually this is a good tradeoff for columns searched more frequently than updated.
This shouldn’t be necessary to resolve performance problems and is generally a bad idea because it complicates and probably slows down join queries later.
It’s generally better to do this if you can.
Time complexity depends heavily on design, indexing etc. 20 million records doing joins on integer keys is not that many if indexed. I think you’ll find that there’s no need to split the database up once you have type farmed out to a lookup table and everything indexed.
The last one seems like it should be mildly more efficient since it doesn’t need to create a new data structure and it can short-circuit further lookups after it finds a match. Not nearly as readable as the map solution though.
The other thing you can do if you need to check the user groups a lot, and you don’t care about group id, is flatten out the groups array into a hashmap.
Then through the rest of the code you can just say (if user.groups.admins). You could even use id as the hashmap value instead of true if you need it somehow.
Haven’t read this thread but did some programming in college. Dad was a programmer (started at like 45 y/o with no degree in late 70s) and brother is a programmer at Raytheon.
Anyway, got sucked into a 110 page PDF “book”, The PhD Grind, last night where a Stanford CS PhD and current prof describes his progress through the degree and the politics and trials and tribulations of completing a CS PhD. Pretty engrossing read.
If a user has their system preferences set to dark theme, is it reasonable to expect that an application they’ve used for some time that only has a light theme be automatically set to dark after its upgraded with that capability?
A better option would providing the user with a dialogue box telling them about the new feature and presenting them with an option to turn it on immediately. Not a fan of apps doing stuff I didn’t ask for.