In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
CREATE INDEX revision_idx_id ON "revision" ("id");
CREATE INDEX revision_idx_has_snapshot ON "revision" ("has_snapshot");
WITH RECURSIVE rev_list (id, parent_revision_id, depth) AS (SELECT
t.id,
t.parent_revision_id,
1
FROM
revision t
WHERE
t.id = $1
UNION
ALL SELECT
t.id,
t.parent_revision_id,
r.depth + 1
FROM
rev_list r
JOIN
revision t
ON t.id = r.parent_revision_id
WHERE
t.has_snapshot = false) SELECT
t.id,
t.parent_revision_id,
t.depth
FROM
rev_list t
ORDER BY
t.id