From: Teodor Sigaev Date: Fri, 18 Sep 2015 15:47:45 +0000 (+0300) Subject: Initial 9.5 X-Git-Url: http://sigaev.ru/git/gitweb.cgi?a=commitdiff_plain;h=dee9b0d93b2b1ffa47cd01817bb9c45f4ee86baa;p=online_analyze.git Initial 9.5 --- diff --git a/online_analyze.c b/online_analyze.c index 299ae57..3f54bab 100644 --- 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 - if ( + if ( 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; +#else + VacuumParams vacstmt; +#endif TimestampTz startStamp, endStamp; memset(&startStamp, 0, sizeof(startStamp)); /* keep compiler quiet */ @@ -381,12 +385,15 @@ makeAnalyze(Oid relOid, CmdType operation, uint32 naffected) 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) @@ -396,17 +403,28 @@ makeAnalyze(Oid relOid, CmdType operation, uint32 naffected) 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 ); @@ -443,15 +461,15 @@ makeAnalyze(Oid relOid, CmdType operation, uint32 naffected) 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 @@ -466,7 +484,7 @@ onlineAnalyzeHooker(QueryDesc *queryDesc) makeAnalyze(relOid, queryDesc->operation, naffected); } - else + else #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); - + if (rte->rtekind == RTE_RELATION) makeAnalyze(rte->relid, queryDesc->operation, naffected); }