3 ms·
Postgres supports json_agg which solves n+1 and also cartesian product problem. It's neat, hasura does it nicely for example.
by tehlike 6y ago
Postgres supports json_agg which solves n+1 and also cartesian product problem. It's neat, hasura does it nicely for example.
- advance512 6y agoHow does json_agg solve the n+1 problem?
- tehlike 6y agoIt can eagerload more complex queries. If you are eagerloading multiple joins relationships, normally that would create a result set of n x m x k x ... rows. With json_agg each relation could be single column in a row etc.
- dmitrytsepelev 6y agoIn this case the row size can become huge. Also, how to make sure it's consistent? (I mean foreign keys/unique indexes/etc)
- tehlike 6y agoi was mostly talking about reading side, not mutation side.