how can i prevent materialized views from refreshing during pg_restore - Mailing list pgsql-hackers

From Kirk Roybal
Subject how can i prevent materialized views from refreshing during pg_restore
Date
Msg-id 39bd13e3689572a6fb2bdc1581c420f7.squirrel@apex.websiteinc.com
Whole thread Raw
Responses Re: how can i prevent materialized views from refreshing during pg_restore  (David G Johnston <david.g.johnston@gmail.com>)
List pgsql-hackers
I asked a question over on StackOverflow, and Craig Ringer told me to
report it here.

http://stackoverflow.com/questions/24413161/how-can-i-prevent-materialized-views-from-refreshing-during-pg-restore

I have created a dump of the database using pg_dump in "custom" format
(-Fc). This format allows for pg_restore to be invoked with the "jobs"
option (-j8). The jobs options starts 8 processes, and restores the vast
majority of relations in my database within 10 minutes.

I'm left with 4 processes. One of them is the refresh of a materialized
view, and the other 3 are indexes to be applied to 3 tables that the
materialized view uses as data sources. The indexes are "waiting"
according to pg_stat_activity, presumably because the REFRESH of the
materialized view is still accessing the source tables.

When the indexes are in place, the refresh of the view only takes a couple
of minutes. Because the indexes are not in place during the REFRESH, I cut
the REFRESH process off at 17 hours, which made pg_restore fail.

How can I
   Force the order of items so the indexes get created first   Turn off the refresh of the materialized view and do it
manuallylater   Manipulate the dump file in custom format to say "WITH NO DATA"   Intercept the REFRESH MATERIALIZED
VIEWstatement and throw it in the
 
trash

Or any other solution that gets the job done?

I have a dump file that I'm willing to send to somebody that seems to
reproduce the problem pretty consistently.


Thank you,
/Kirk




pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: better atomics - v0.5
Next
From: Vik Fearing
Date:
Subject: Re: ALTER SYSTEM RESET?