@@ -53,7 +53,7 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_at_date (
5353 -- This prevents race conditions where new notes are inserted while processing
5454 SELECT COALESCE(MAX (note_id), 0 )
5555 INTO max_note_id_snapshot
56- FROM notes;
56+ FROM public . notes ;
5757-- RAISE NOTICE 'Day % started.', max_processed_timestamp;
5858
5959-- RAISE NOTICE 'Flag 1: %', CLOCK_TIMESTAMP();
@@ -75,17 +75,17 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_at_date (
7575 n.created_at created_at, o.id_user created_id_user, n.id_country id_country,
7676 c.sequence_action seq, c.event action_comment, c.id_user action_id_user,
7777 c.created_at action_at, t.body
78- FROM note_comments c
79- JOIN notes n
78+ FROM public. note_comments c
79+ JOIN public. notes n
8080 ON (c.note_id = n.note_id)
81- JOIN note_comments o
81+ JOIN public. note_comments o
8282 ON (n.note_id = o.note_id
8383 -- Direct enum comparison (no CAST needed): foreign table is defined as note_event_enum
8484 -- ETL_60_setupFDW.sql ensures the foreign table uses note_event_enum type, not TEXT
8585 -- This allows PostgreSQL to use indexes and avoids full table scans
8686 AND o.event = ' ' opened' '
8787 AND o.note_id <= ' || max_note_id_snapshot || ' )
88- LEFT JOIN note_comments_text t
88+ LEFT JOIN public. note_comments_text t
8989 ON (c.note_id = t.note_id AND c.sequence_action = t.sequence_action)
9090
9191 WHERE c.created_at >= ' ' ' || max_processed_timestamp
@@ -101,17 +101,17 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_at_date (
101101 n.created_at created_at, o.id_user created_id_user, n.id_country id_country,
102102 c.sequence_action seq, c.event action_comment, c.id_user action_id_user,
103103 c.created_at action_at, t.body
104- FROM note_comments c
105- JOIN notes n
104+ FROM public. note_comments c
105+ JOIN public. notes n
106106 ON (c.note_id = n.note_id)
107- JOIN note_comments o
107+ JOIN public. note_comments o
108108 ON (n.note_id = o.note_id
109109 -- Direct enum comparison (no CAST needed): foreign table is defined as note_event_enum
110110 -- ETL_60_setupFDW.sql ensures the foreign table uses note_event_enum type, not TEXT
111111 -- This allows PostgreSQL to use indexes and avoids full table scans
112112 AND o.event = ' ' opened' '
113113 AND o.note_id <= ' || max_note_id_snapshot || ' )
114- LEFT JOIN note_comments_text t
114+ LEFT JOIN public. note_comments_text t
115115 ON (c.note_id = t.note_id AND c.sequence_action = t.sequence_action)
116116
117117 WHERE c.created_at > ' ' ' || max_processed_timestamp
@@ -144,7 +144,7 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_at_date (
144144 INSERT INTO dwh .dimension_countries
145145 (country_id, country_name, country_name_es, country_name_en)
146146 SELECT /* Notes-staging */ c .country_id , c .country_name , c .country_name_es , c .country_name_en
147- FROM countries c
147+ FROM public . countries c
148148 WHERE c .country_id = rec_note_action .id_country
149149 AND c .country_id NOT IN (SELECT country_id FROM dwh .dimension_countries )
150150 ON CONFLICT (country_id) DO NOTHING
@@ -286,7 +286,7 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_at_date (
286286 -- be executed in READ ONLY mode for better concurrency, but this procedure also
287287 -- performs writes, so READ ONLY cannot be applied to the entire transaction.
288288 SELECT n .latitude , n .longitude INTO m_latitude, m_longitude
289- FROM notes n WHERE n .note_id = rec_note_action .id_note ;
289+ FROM public . notes n WHERE n .note_id = rec_note_action .id_note ;
290290 m_timezone_id := dwh .get_timezone_id_by_lonlat (m_longitude, m_latitude);
291291 m_local_action_id_date := dwh .get_local_date_id (rec_note_action .action_at , m_timezone_id);
292292 m_local_action_id_hour_of_week := dwh .get_local_hour_of_week_id (rec_note_action .action_at , m_timezone_id);
@@ -428,7 +428,7 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_actions_into_dwh (
428428 -- This prevents race conditions where new notes are inserted while processing
429429 SELECT COALESCE(MAX (note_id), 0 )
430430 INTO max_note_id_snapshot
431- FROM notes;
431+ FROM public . notes ;
432432
433433 -- Use this snapshot for all queries to ensure referential integrity
434434 -- All note_comments processed will have their corresponding notes
@@ -466,14 +466,14 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_actions_into_dwh (
466466 -- Filter by max_note_id_snapshot to ensure consistency
467467 SELECT /* Notes-staging */ MAX (DATE (created_at))
468468 INTO max_note_action_date
469- FROM note_comments
469+ FROM public . note_comments
470470 WHERE note_id <= max_note_id_snapshot;
471471
472472 -- Start from the first date with comments
473473 -- Filter by max_note_id_snapshot to ensure consistency
474474 SELECT /* Notes-staging */ MIN (DATE (created_at))
475475 INTO max_processed_date
476- FROM note_comments
476+ FROM public . note_comments
477477 WHERE note_id <= max_note_id_snapshot;
478478
479479 -- Process all dates from first date until the latest date (skip empty days)
@@ -495,7 +495,7 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_actions_into_dwh (
495495 -- OPTIMIZATION: Use timestamp range instead of DATE() to allow index usage on FDW
496496 SELECT /* Notes-staging */ COUNT (1 )
497497 INTO qty_notes_on_date
498- FROM note_comments
498+ FROM public . note_comments
499499 WHERE created_at >= max_processed_date::TIMESTAMP
500500 AND created_at < (max_processed_date + INTERVAL ' 1 day' )::TIMESTAMP
501501 AND created_at > max_note_on_dwh_timestamp
@@ -512,8 +512,8 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_actions_into_dwh (
512512 -- OPTIMIZATION: Use timestamp range instead of DATE() to allow index usage on FDW
513513 SELECT /* Notes-staging */ MIN (DATE (created_at))
514514 INTO max_processed_date
515- FROM note_comments
516- WHERE created_at >= (max_processed_date + INTERVAL ' 1 day' )::TIMESTAMP
515+ FROM public . note_comments
516+ WHERE created_at >= (max_processed_date + INTERVAL ' 1 day' )::TIMESTAMP
517517 AND note_id <= max_note_id_snapshot;
518518
519519 -- If no more dates with comments, exit loop
@@ -556,7 +556,7 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_actions_into_dwh (
556556 -- Filter by max_note_id_snapshot to ensure consistency
557557 SELECT /* Notes-staging */ MAX (DATE (created_at))
558558 INTO max_note_action_date
559- FROM note_comments
559+ FROM public . note_comments
560560 WHERE note_id <= max_note_id_snapshot;
561561-- RAISE NOTICE 'Max date with comments in base tables: %', max_note_action_date;
562562-- RAISE NOTICE '1Flag 4: %', CLOCK_TIMESTAMP();
@@ -605,13 +605,13 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_actions_into_dwh (
605605 -- processed.
606606 -- Filter by max_note_id_snapshot to ensure consistency
607607 -- OPTIMIZATION: Use timestamp range instead of DATE() to allow index usage on FDW
608- SELECT /* Notes-staging */ COUNT (1 )
609- INTO qty_notes_on_date
610- FROM note_comments
611- WHERE created_at >= max_processed_date::TIMESTAMP
612- AND created_at < (max_processed_date + INTERVAL ' 1 day' )::TIMESTAMP
613- AND created_at > max_note_on_dwh_timestamp
614- AND note_id <= max_note_id_snapshot;
608+ SELECT /* Notes-staging */ COUNT (1 )
609+ INTO qty_notes_on_date
610+ FROM public . note_comments
611+ WHERE created_at >= max_processed_date::TIMESTAMP
612+ AND created_at < (max_processed_date + INTERVAL ' 1 day' )::TIMESTAMP
613+ AND created_at > max_note_on_dwh_timestamp
614+ AND note_id <= max_note_id_snapshot;
615615-- RAISE NOTICE 'count notes to process on date %: %.', max_processed_date,
616616-- qty_notes_on_date;
617617-- RAISE NOTICE '1Flag 7: %', CLOCK_TIMESTAMP();
@@ -625,8 +625,8 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_actions_into_dwh (
625625 -- OPTIMIZATION: Use timestamp range instead of DATE() to allow index usage on FDW
626626 SELECT /* Notes-staging */ MIN (DATE (created_at))
627627 INTO max_processed_date
628- FROM note_comments
629- WHERE created_at >= (max_processed_date + INTERVAL ' 1 day' )::TIMESTAMP
628+ FROM public . note_comments
629+ WHERE created_at >= (max_processed_date + INTERVAL ' 1 day' )::TIMESTAMP
630630 AND note_id <= max_note_id_snapshot;
631631
632632 -- If no more dates with comments, exit loop
@@ -671,7 +671,7 @@ CREATE OR REPLACE PROCEDURE staging.process_notes_actions_into_dwh (
671671 -- OPTIMIZATION: Use timestamp range instead of DATE() to allow index usage on FDW
672672 SELECT /* Notes-staging */ COUNT (1 )
673673 INTO qty_notes_on_date
674- FROM note_comments
674+ FROM public . note_comments
675675 WHERE created_at >= max_processed_date::TIMESTAMP
676676 AND created_at < (max_processed_date + INTERVAL ' 1 day' )::TIMESTAMP
677677 AND created_at > max_note_on_dwh_timestamp
0 commit comments