{
  "db_name": "PostgreSQL",
  "query": "\nWITH RECURSIVE job_tree AS (\n    -- Base case: direct children of the given parent job\n    SELECT id, parent_job, 1 AS depth\n    FROM v2_job_queue\n    INNER JOIN v2_job USING (id)\n    WHERE parent_job = $1 AND v2_job.workspace_id = $2\n\n    UNION ALL\n\n    -- Recursive case: fetch children of previously found jobs\n    SELECT q.id, j.parent_job, t.depth + 1\n    FROM v2_job_queue q\n    INNER JOIN v2_job j USING (id)\n    INNER JOIN job_tree t ON t.id = j.parent_job\n    WHERE j.workspace_id = $2 AND t.depth < 500  -- Limit recursion depth to 500\n)\nSELECT id AS id, depth\nFROM job_tree\nORDER BY depth, id\n        ",
  "describe": {
    "columns": [
      {
        "ordinal": 0,
        "name": "id",
        "type_info": "Uuid"
      },
      {
        "ordinal": 1,
        "name": "depth",
        "type_info": "Int4"
      }
    ],
    "parameters": {
      "Left": [
        "Uuid",
        "Text"
      ]
    },
    "nullable": [
      null,
      null
    ]
  },
  "hash": "b22e933ea5e9297dd4342310b0561fb43786010f410693e26c9d564e5eff09ff"
}
