A machine-readable storage medium storing one or more sequences of instructions, which when executed by one or more processors, causes the one or more processors to perform a method for refreshing indexes of a materialized view in a database system, the method comprising:
- determining whether an incremental refresh of the materialized view satisfies one or more criteria, wherein an index on the materialized view is refreshable by incrementally refreshing the index as the incremental refresh of the materialized view is being performed or by delayed maintenance of the index until after the materialized view is refreshed;
- wherein the index is not any materialized view that is referable as a table in database statements that are executable by the database system;
- when the one or more criteria are satisfied,
- disabling incremental updating of the index, refreshing the materialized view, and, after refreshing the materialized view, performing the delayed maintenance of the index;
- when the one or more criteria are not satisfied, incrementally refreshing the index as the incremental refresh of the materialized view is being performed.