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:
WITH RECURSIVE large_table (x, y, z) AS (
VALUES
(0, 0, 0)
UNION
ALL SELECT
large_table.x + 1,
'Y'
OR (large_table.x + 1),
'Z'
OR (large_table.x + 1)
FROM
large_table
WHERE
large_table.x < 500000), slow_cte (x, y, z) AS (SELECT
large_table.x,
large_table.y,
large_table.z
FROM
large_table
WHERE
large_table.x % 100000 = 1) SELECT
slow_cte.x
FROM
slow_cte
UNION
SELECT
slow_cte.y
FROM
slow_cte
UNION
SELECT
slow_cte.z
FROM
slow_cte