A specific query to recreate views is taking very long, sometimes up to 8 hours.
STEPS TO REPRODUCE:
Expected Results: The DWH job to run correctly
Actual Results: At least one Incremental instance per day is taking a lot more time to complete. A session on the database is taking over 8 hours and sometimes over 10 hours and getting automatically terminated
The below session running for 8+ hours:
SELECT ('CREATE OR REPLACE VIEW ' || a.fact_view || ' AS ') AS operation,
+
a.fact_view,
+
a.column_name,
+
'COMMENT ON VIEW ' || a.fact_view || ' IS ''' || coalesce(utc.comments, ' ') || ''';' AS view_comment,
+
'COMMENT ON COLUMN ' || a.fact_view || '.' || a.simple_col_name || ' IS ''' || coalesce(ucc.comments, ' ') || ''';' AS column_comment,
+
a.ordinal_position
+
FROM (SELECT DISTINCT
+
map.fact_view,
+
(c.table_name || '.' || c.column_name) || (CASE WHEN map.suffix IS NULL THEN '' ELSE (' AS ' || c.column_name || '_' || map.suffix) END) AS co
lumn_name
(CASE WHEN map.suffix IS NULL THEN c.column_name ELSE (c.column_name || '_' || map.suffix) END) AS simple_col_name,
+
CAST(c.ordinal_position AS VARCHAR) AS ordinal_position
+
FROM information_schema.columns c
+
INNER JOIN (SELECT fact_view, has_tsv, tsv_table AS table_name, tsv_key AS key_col, tsv_period_key AS period_key_col, suffix
Clarity 16.3.3 with PostgreSQL
DE176575
In review by Engineering, targeted for 16.4.0
Workaround: