Why do developers make stupid database queries
@wolf480pl Usually because they have a mismatch between their mental model of how the database system works, and how it actually works.
It can be faster, with some big ifs attached: what's the ratio of internal performance to external IO? Is the data stored in a format that rewards simple streaming of unfiltered datasets with minimal interference? And so on.
Also, it depends on the developer's other purposes: is it part of a function that might be called many times to fetch multiple users, thus motivating fetching lots and caching the data once versus fifty individual calls?
And sometimes they're just wrong.
>is it part of a function that might be called many times to fetch multiple users
No, it's called only once per request.
>Is the data stored in a format that rewards simple streaming?
No, it's a good old relational database, and then they need to do other queries to filter out users who shouldn't be visible.
Then they check if the user specified in URL is in the set of visible users.
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!