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:
f248b98
)
Initial 9.5
author
Teodor Sigaev
<teodor@sigaev.ru>
Fri, 18 Sep 2015 15:47:45 +0000
(18:47 +0300)
committer
Teodor Sigaev
<teodor@sigaev.ru>
Fri, 18 Sep 2015 15:47:45 +0000
(18:47 +0300)
online_analyze.c
patch
|
blob
|
history
diff --git
a/online_analyze.c
b/online_analyze.c
index
299ae57
..
3f54bab
100644
(file)
--- a/
online_analyze.c
+++ b/
online_analyze.c
@@
-321,7
+321,7
@@
makeAnalyze(Oid relOid, CmdType operation, uint32 naffected)
#define changes_since_analyze(t) ((t)->n_live_tuples + (t)->n_dead_tuples - (t)->last_anl_tuples)
#endif
#define changes_since_analyze(t) ((t)->n_live_tuples + (t)->n_dead_tuples - (t)->last_anl_tuples)
#endif
- if (
+ if (
tabentry == NULL /* a new table */ ||
(
/* do not analyze too often, if both stamps are exceeded the go */
tabentry == NULL /* a new table */ ||
(
/* do not analyze too often, if both stamps are exceeded the go */
@@
-334,7
+334,11
@@
makeAnalyze(Oid relOid, CmdType operation, uint32 naffected)
)
)
{
)
)
{
+#if PG_VERSION_NUM < 90500
VacuumStmt vacstmt;
VacuumStmt vacstmt;
+#else
+ VacuumParams vacstmt;
+#endif
TimestampTz startStamp, endStamp;
memset(&startStamp, 0, sizeof(startStamp)); /* keep compiler quiet */
TimestampTz startStamp, endStamp;
memset(&startStamp, 0, sizeof(startStamp)); /* keep compiler quiet */
@@
-381,12
+385,15
@@
makeAnalyze(Oid relOid, CmdType operation, uint32 naffected)
break;
}
break;
}
- vacstmt.type = T_VacuumStmt;
+ memset(&vacstmt, 0, sizeof(vacstmt));
+
vacstmt.freeze_min_age = -1;
vacstmt.freeze_table_age = -1; /* ??? */
vacstmt.freeze_min_age = -1;
vacstmt.freeze_table_age = -1; /* ??? */
+
+#if PG_VERSION_NUM < 90500
+ vacstmt.type = T_VacuumStmt;
vacstmt.relation = NULL;
vacstmt.va_cols = NIL;
vacstmt.relation = NULL;
vacstmt.va_cols = NIL;
-
#if PG_VERSION_NUM >= 90000
vacstmt.options = VACOPT_ANALYZE;
if (online_analyze_verbose)
#if PG_VERSION_NUM >= 90000
vacstmt.options = VACOPT_ANALYZE;
if (online_analyze_verbose)
@@
-396,17
+403,28
@@
makeAnalyze(Oid relOid, CmdType operation, uint32 naffected)
vacstmt.analyze = true;
vacstmt.verbose = online_analyze_verbose;
#endif
vacstmt.analyze = true;
vacstmt.verbose = online_analyze_verbose;
#endif
+#else
+ vacstmt.multixact_freeze_min_age = -1;
+ vacstmt.multixact_freeze_table_age = -1;
+ vacstmt.log_min_duration = -1;
+#endif
if (online_analyze_verbose)
startStamp = GetCurrentTimestamp();
if (online_analyze_verbose)
startStamp = GetCurrentTimestamp();
- analyze_rel(relOid, &vacstmt
+ analyze_rel(relOid,
+#if PG_VERSION_NUM < 90500
+ &vacstmt
#if PG_VERSION_NUM >= 90018
, true
#endif
, GetAccessStrategy(BAS_VACUUM)
#if (PG_VERSION_NUM >= 90000) && (PG_VERSION_NUM < 90004)
, true
#if PG_VERSION_NUM >= 90018
, true
#endif
, GetAccessStrategy(BAS_VACUUM)
#if (PG_VERSION_NUM >= 90000) && (PG_VERSION_NUM < 90004)
, true
+#endif
+#else
+ NULL /*RangeVar*/, VACOPT_ANALYZE | ((online_analyze_verbose) ? VACOPT_VERBOSE : 0),
+ &vacstmt, NULL, true, GetAccessStrategy(BAS_VACUUM)
#endif
);
#endif
);
@@
-443,15
+461,15
@@
makeAnalyze(Oid relOid, CmdType operation, uint32 naffected)
extern PGDLLIMPORT void onlineAnalyzeHooker(QueryDesc *queryDesc);
void
extern PGDLLIMPORT void onlineAnalyzeHooker(QueryDesc *queryDesc);
void
-onlineAnalyzeHooker(QueryDesc *queryDesc)
+onlineAnalyzeHooker(QueryDesc *queryDesc)
{
uint32 naffected = 0;
if (queryDesc->estate)
{
uint32 naffected = 0;
if (queryDesc->estate)
- naffected = queryDesc->estate->es_processed;
+ naffected = queryDesc->estate->es_processed;
if (online_analyze_enable && queryDesc->plannedstmt &&
if (online_analyze_enable && queryDesc->plannedstmt &&
- (queryDesc->operation == CMD_INSERT ||
+ (queryDesc->operation == CMD_INSERT ||
queryDesc->operation == CMD_UPDATE ||
queryDesc->operation == CMD_DELETE
#if PG_VERSION_NUM < 90200
queryDesc->operation == CMD_UPDATE ||
queryDesc->operation == CMD_DELETE
#if PG_VERSION_NUM < 90200
@@
-466,7
+484,7
@@
onlineAnalyzeHooker(QueryDesc *queryDesc)
makeAnalyze(relOid, queryDesc->operation, naffected);
}
makeAnalyze(relOid, queryDesc->operation, naffected);
}
- else
+ else
#endif
if (queryDesc->plannedstmt->resultRelations &&
queryDesc->plannedstmt->rtable)
#endif
if (queryDesc->plannedstmt->resultRelations &&
queryDesc->plannedstmt->rtable)
@@
-477,7
+495,7
@@
onlineAnalyzeHooker(QueryDesc *queryDesc)
{
int n = lfirst_int(l);
RangeTblEntry *rte = list_nth(queryDesc->plannedstmt->rtable, n-1);
{
int n = lfirst_int(l);
RangeTblEntry *rte = list_nth(queryDesc->plannedstmt->rtable, n-1);
-
+
if (rte->rtekind == RTE_RELATION)
makeAnalyze(rte->relid, queryDesc->operation, naffected);
}
if (rte->rtekind == RTE_RELATION)
makeAnalyze(rte->relid, queryDesc->operation, naffected);
}