From: Teodor Sigaev Date: Thu, 20 Apr 2017 14:05:04 +0000 (+0300) Subject: add support for vacuum/analyze X-Git-Url: http://sigaev.ru/git/gitweb.cgi?a=commitdiff_plain;h=438dde9c48a4f7372a765cc7ec69eb5bdd9a9edc;hp=fad4d8cc9583a40434b26142ce73b40225f8f4fa;p=online_analyze.git add support for vacuum/analyze --- diff --git a/online_analyze.c b/online_analyze.c index b710d47..c70b1bb 100644 --- a/online_analyze.c +++ b/online_analyze.c @@ -83,7 +83,9 @@ typedef enum CmdKind CK_DELETE = CMD_DELETE, CK_TRUNCATE, CK_FASTTRUNCATE, - CK_CREATE + CK_CREATE, + CK_ANALYZE, + CK_VACUUM } CmdKind; @@ -442,6 +444,18 @@ makeAnalyze(Oid relOid, CmdKind operation, int64 naffected) rstat->tableid = relOid; newTable = true; } + else if (operation == CK_VACUUM) + { + /* force reread becouse vacuum could change n_tuples */ + rstat->rereadStat = true; + return; + } + else if (operation == CK_ANALYZE) + { + /* only analyze */ + rstat->changes_since_analyze = 0; + return; + } Assert(rstat->tableid == relOid); @@ -772,6 +786,20 @@ onlineAnalyzeHookerUtility( tblnames = list_copy(((TruncateStmt*)parsetree)->relations); op = CK_TRUNCATE; } + else if (IsA(parsetree, VacuumStmt)) + { + VacuumStmt *vac = (VacuumStmt*)parsetree; + + tblnames = list_make1(vac->relation); + + if (vac->options & (VACOPT_VACUUM | VACOPT_FULL | VACOPT_FREEZE)) + /* optionally with analyze */ + op = CK_VACUUM; + else if (vac->options & VACOPT_ANALYZE) + op = CK_ANALYZE; + else + tblnames = NIL; + } } #if PG_VERSION_NUM >= 100000