How can I measure the CTE execution time? I want to be able to log the time between CTEs. E.g like this :
--log time here 1 -> insert into log(...) values(...)
WITH cte1
AS (
SELECT 1 AS id
)
--log time here 2-> insert into log(...) values(...)
,cte2
AS (
SELECT 2 AS id
)
--log time here 3-> insert into log(...) values(...)
SELECT *
FROM cte1
UNION ALL
SELECT *
FROM cte2