Postgresql: Refreshing materialized view fails with "No space left on device" and a huge spike in disk usage
Find where postgres writes temp files for you and follow it during the refresh. As you are processing alot of data inside the database, postgres has to write a huge temp file and as this fills your disk, you get an error.
You probably have to find a more efficent way to write your query.