3 ms·
this. JSON Agg fixes the cartesian product problem. Imagine having a table with large rows, and another table to join with small data but many rows. Normally
by tehlike 5y ago
this. JSON Agg fixes the cartesian product problem.
Imagine having a table with large rows, and another table to join with small data but many rows.
Normally you'd do a inner join of some sort, and the data from "large rows" would be duplicated many many times - json_agg simply fixes this.
you can actually do the full table without json_build_object, too you can do something like
select json_agg(t.) from (
select from table
) as t
this makes joining multiple tables together very very easy, and performant.