Slide 45
Slide 45 text
SELECT
row_to_json("accounts")
FROM (
SELECT
*
, (
SELECT
array_agg(row_to_json("delegates"))
FROM (
SELECT
*
, (
SELECT
row_to_json("groups")
FROM (SELECT * FROM "groups") AS "groups"
WHERE
(
"groups".id = "delegates"."group_id"
)) AS "group"
FROM "delegates") AS "delegates"
WHERE
(
"delegates"."account_id" = "accounts".id
)) AS "delegates"
FROM "accounts") AS "accounts"
N+1