diff options
| author | Kevin Grittner <kgrittn@postgresql.org> | 2013-05-02 17:33:03 -0500 |
|---|---|---|
| committer | Kevin Grittner <kgrittn@postgresql.org> | 2013-05-02 17:33:03 -0500 |
| commit | b69ec7cc990fd8da75ed4c232899503217d7b9ae (patch) | |
| tree | 2898b53f262e17a819eb3fa828da5dc3ab915d7a /src/backend/commands | |
| parent | 095018bc32b70eff95bdf3c2959e6eef09dcfa6a (diff) | |
Prevent (auto)vacuum from truncating first page of populated matview.
Per report from Fujii Masao, with regression test using his example.
Diffstat (limited to 'src/backend/commands')
| -rw-r--r-- | src/backend/commands/vacuumlazy.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 9d304153b8b..02f3cf3c205 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -230,7 +230,13 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt, * * Don't even think about it unless we have a shot at releasing a goodly * number of pages. Otherwise, the time taken isn't worth it. + * + * Leave a populated materialized view with at least one page. */ + if (onerel->rd_rel->relkind == RELKIND_MATVIEW && + vacrelstats->nonempty_pages == 0) + vacrelstats->nonempty_pages = 1; + possibly_freeable = vacrelstats->rel_pages - vacrelstats->nonempty_pages; if (possibly_freeable > 0 && (possibly_freeable >= REL_TRUNCATE_MINIMUM || |
