#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 */
)
)
{
+#if PG_VERSION_NUM < 90500
VacuumStmt vacstmt;
+#else
+ VacuumParams vacstmt;
+#endif
TimestampTz startStamp, endStamp;
memset(&startStamp, 0, sizeof(startStamp)); /* keep compiler quiet */
break;
}
- vacstmt.type = T_VacuumStmt;
+ memset(&vacstmt, 0, sizeof(vacstmt));
+
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;
-
#if PG_VERSION_NUM >= 90000
vacstmt.options = VACOPT_ANALYZE;
if (online_analyze_verbose)
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();
- 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
+#endif
+#else
+ NULL /*RangeVar*/, VACOPT_ANALYZE | ((online_analyze_verbose) ? VACOPT_VERBOSE : 0),
+ &vacstmt, NULL, true, GetAccessStrategy(BAS_VACUUM)
#endif
);
extern PGDLLIMPORT void onlineAnalyzeHooker(QueryDesc *queryDesc);
void
-onlineAnalyzeHooker(QueryDesc *queryDesc)
+onlineAnalyzeHooker(QueryDesc *queryDesc)
{
uint32 naffected = 0;
if (queryDesc->estate)
- naffected = queryDesc->estate->es_processed;
+ naffected = queryDesc->estate->es_processed;
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
makeAnalyze(relOid, queryDesc->operation, naffected);
}
- else
+ else
#endif
if (queryDesc->plannedstmt->resultRelations &&
queryDesc->plannedstmt->rtable)
{
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);
}