|
|
|
|
|
by uhoh-itsmaciek
2458 days ago
|
|
>Am I the only one that thinks rails/activerecord is crazy here for (often) preferring two trips to the db over a join on indexed primary keys? You mean SELECT u.* , c.* FROM users u INNER JOIN comments c
ON u.id = c.user_id WHERE u.id = <...>
?If the average user record includes a non-trivial amount of data and there are many comments, you're repeating a lot of information in the query results. disclaimer: I'm currently doing some work for pganalyze.com (the blog host) |
|
I'm not sure about "non-trivial amount of data" - especially if we're talking about a single row (single user) here? I suppose there might be a few blolbs of large json documents?
And I'm not sure I understand "repeating information in query results" - surely we're talking about receiving a query, transforming it and responding with the data?
In a rails+graphql ideal world, that'd maybe mean Parsing the json query, generate some simple ruby (active record) code, fire it off to the db (let ar /arel do its job; generate sql) - serialize to json and write the response?
If there truly is non-trivial data in fields not requested, it might be worth it to naemrrow the columns selected. But I doubt it, in the general case.