projects
/
online_analyze.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fad4d8c
)
add support for vacuum/analyze
author
Teodor Sigaev
<teodor@sigaev.ru>
Thu, 20 Apr 2017 14:05:04 +0000
(17:05 +0300)
committer
Teodor Sigaev
<teodor@sigaev.ru>
Thu, 20 Apr 2017 14:05:04 +0000
(17:05 +0300)
online_analyze.c
patch
|
blob
|
history
diff --git
a/online_analyze.c
b/online_analyze.c
index
b710d47
..
c70b1bb
100644
(file)
--- a/
online_analyze.c
+++ b/
online_analyze.c
@@
-83,7
+83,9
@@
typedef enum CmdKind
CK_DELETE = CMD_DELETE,
CK_TRUNCATE,
CK_FASTTRUNCATE,
CK_DELETE = CMD_DELETE,
CK_TRUNCATE,
CK_FASTTRUNCATE,
- CK_CREATE
+ CK_CREATE,
+ CK_ANALYZE,
+ CK_VACUUM
} CmdKind;
} CmdKind;
@@
-442,6
+444,18
@@
makeAnalyze(Oid relOid, CmdKind operation, int64 naffected)
rstat->tableid = relOid;
newTable = true;
}
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);
Assert(rstat->tableid == relOid);
@@
-772,6
+786,20
@@
onlineAnalyzeHookerUtility(
tblnames = list_copy(((TruncateStmt*)parsetree)->relations);
op = CK_TRUNCATE;
}
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
}
#if PG_VERSION_NUM >= 100000