graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:3px,color:#000
    classDef itemplan fill:#fff,stroke-width:6px,color:#000
    classDef sideeffectplan fill:#f00,stroke-width:6px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:6px,text-align:left


    %% define plans
    __Value0["__Value[0∈0]"]:::plan
    __Value3["__Value[3∈0]<br />ᐸcontextᐳ"]:::plan
    Access8["Access[8∈0]<br />ᐸ3.pgSettingsᐳ"]:::plan
    Access9["Access[9∈0]<br />ᐸ3.withPgClientᐳ"]:::plan
    Object10["Object[10∈0]<br />ᐸ{pgSettings,withPgClient}ᐳ"]:::plan
    Connection11["Connection[11∈0]<br />ᐸ7ᐳ"]:::plan
    PgSelect12[["PgSelect[12∈0]<br />ᐸbadly_behaved_functionᐳ"]]:::plan
    __Item13>"__Item[13∈1]<br />ᐸ12ᐳ"]:::itemplan
    PgSelectSingle14["PgSelectSingle[14∈1]<br />ᐸbadly_behaved_functionᐳ"]:::plan
    Constant15["Constant[15∈0]"]:::plan
    PgClassExpression16["PgClassExpression[16∈1]<br />ᐸ__badly_be...ion__.”id”ᐳ"]:::plan
    List17["List[17∈1]<br />ᐸ15,16ᐳ"]:::plan
    Lambda18["Lambda[18∈1]<br />ᐸencodeᐳ"]:::plan
    PgClassExpression21["PgClassExpression[21∈1]<br />ᐸ”c”.”perso...unction__)ᐳ"]:::plan
    PgClassExpression25["PgClassExpression[25∈1]<br />ᐸrow_number...tion by 1)ᐳ"]:::plan
    List26["List[26∈1]<br />ᐸ25ᐳ"]:::plan
    PgCursor24["PgCursor[24∈1]"]:::plan
    Constant27["Constant[27∈0]"]:::plan
    List29["List[29∈1]<br />ᐸ27,16ᐳ"]:::plan
    Lambda30["Lambda[30∈1]<br />ᐸencodeᐳ"]:::plan

    %% plan dependencies
    __Value3 --> Access8
    __Value3 --> Access9
    Access8 & Access9 --> Object10
    Object10 & Connection11 --> PgSelect12
    PgSelect12 ==> __Item13
    __Item13 --> PgSelectSingle14
    PgSelectSingle14 --> PgClassExpression16
    Constant15 & PgClassExpression16 --> List17
    List17 --> Lambda18
    PgSelectSingle14 --> PgClassExpression21
    PgSelectSingle14 --> PgClassExpression25
    PgClassExpression25 --> List26
    List26 --> PgCursor24
    Constant27 & PgClassExpression16 --> List29
    List29 --> Lambda30

    %% plan-to-path relationships
    P0["~"]
    __Value0 -.-> P0
    P11["ᐳbadlyBehavedFunction"]
    Connection11 -.-> P11
    P12["ᐳb…nᐳnodes<br />ᐳb…nᐳedges"]
    PgSelect12 -.-> P12
    P14["ᐳb…nᐳnodes[]<br />ᐳb…nᐳedges[]<br />ᐳb…nᐳe…]ᐳnode"]
    PgSelectSingle14 -.-> P14
    P16["ᐳb…nᐳn…]ᐳid<br />ᐳb…nᐳe…]ᐳnodeᐳid"]
    PgClassExpression16 -.-> P16
    P18["ᐳb…nᐳn…]ᐳnodeId"]
    Lambda18 -.-> P18
    P21["ᐳb…nᐳn…]ᐳfirstName<br />ᐳb…nᐳe…]ᐳnodeᐳfirstName"]
    PgClassExpression21 -.-> P21
    P24["ᐳb…nᐳe…]ᐳcursor"]
    PgCursor24 -.-> P24
    P30["ᐳb…nᐳe…]ᐳnodeᐳnodeId"]
    Lambda30 -.-> P30

    subgraph "Buckets for queries/v4/badlyBehavedFunction"
    Bucket0("Bucket 0 (root)<br />~<br />⠀ROOT ᐸ-O- 0<br />⠀⠀badlyBehavedFunction ᐸ-O- 11<br />⠀⠀⠀badlyBehavedFunction.nodes ᐸ-A- 12<br />⠀⠀⠀badlyBehavedFunction.edges ᐸ-A- 12"):::bucket
    classDef bucket0 stroke:#696969
    class Bucket0,__Value0,__Value3,Access8,Access9,Object10,Connection11,PgSelect12,Constant15,Constant27 bucket0
    Bucket1("Bucket 1 (item13)<br />Deps: 12, 15, 27<br />~ᐳQuery.badlyBehavedFunctionᐳPeopleConnection.nodes[]<br />~ᐳQuery.badlyBehavedFunctionᐳPeopleConnection.edges[]<br />⠀ROOT ᐸ-O- 14<br />⠀⠀node ᐸ-O- 14<br />⠀⠀⠀node.id ᐸ-L- 16<br />⠀⠀⠀node.firstName ᐸ-L- 21<br />⠀⠀⠀node.nodeId ᐸ-L- 30<br />⠀⠀id ᐸ-L- 16<br />⠀⠀nodeId ᐸ-L- 18<br />⠀⠀firstName ᐸ-L- 21<br />⠀⠀cursor ᐸ-L- 24"):::bucket
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item13,PgSelectSingle14,PgClassExpression16,List17,Lambda18,PgClassExpression21,PgCursor24,PgClassExpression25,List26,List29,Lambda30 bucket1
    Bucket0 --> Bucket1
    end
