everyone. In postgresql 12, i have a materialized view like this:
CREATE MATERIALIZED VIEW mv
AS
WITH cte AS (SELECT ...), cte2 AS (SELECT ...) SELECT ...
WITH DATA;
when i invoke
REFRESH MATERIALIZED VIEW mv
, or perform this command in linux crontab, it cost 4 hours.
but i perform WITH cte AS (SELECT ...), cte2 AS (SELECT ...) SELECT ...
in pgadmin4 Query Tool, it only cost 7 seconds.
I don't know why it's too diffrence. I would like to cost 7 seconds in crontab, What shoud i do?