From: Teodor Sigaev Date: Wed, 10 May 2017 15:02:24 +0000 (+0300) Subject: add locl_tracking GUC X-Git-Url: http://sigaev.ru/git/gitweb.cgi?p=online_analyze.git;a=commitdiff_plain;h=134c5a4d5ebbfa1fc11446484217ef1c73418a2e add locl_tracking GUC --- diff --git a/README.online_analyze b/README.online_analyze index f7d2942..d72f17d 100644 --- a/README.online_analyze +++ b/README.online_analyze @@ -10,6 +10,9 @@ Custom variables (defaults values are shown): online_analyze.enable = on Enables on-line analyze +online_analyze.local_tracking = off + Per backend tracking for temp tables (do not use system statistic) + online_analyze.verbose = on Execute ANALYZE VERBOSE diff --git a/online_analyze.c b/online_analyze.c index c70b1bb..90755e2 100644 --- a/online_analyze.c +++ b/online_analyze.c @@ -63,6 +63,7 @@ PG_MODULE_MAGIC; #endif static bool online_analyze_enable = true; +static bool online_analyze_local_tracking = false; static bool online_analyze_verbose = true; static double online_analyze_scale_factor = 0.1; static int online_analyze_threshold = 50; @@ -454,14 +455,20 @@ makeAnalyze(Oid relOid, CmdKind operation, int64 naffected) { /* only analyze */ rstat->changes_since_analyze = 0; + rstat->analyze_timestamp = now; return; } Assert(rstat->tableid == relOid); - /* do not rered data if it was a truncation */ - if (operation != CK_TRUNCATE && operation != CK_FASTTRUNCATE && - (newTable == true || rstat->rereadStat == true)) + if ( + /* do not reread data if it was a truncation */ + operation != CK_TRUNCATE && operation != CK_FASTTRUNCATE && + /* read for persistent table and for temp teble if it allowed */ + (reltype == OATT_PERSISTENT || online_analyze_local_tracking == false) && + /* read only for new table or we know that it's needed */ + (newTable == true || rstat->rereadStat == true) + ) { rstat->rereadStat = false; @@ -926,6 +933,25 @@ _PG_init(void) NULL ); + DefineCustomBoolVariable( + "online_analyze.local_tracking", + "Per backend tracking", + "Per backend tracking for temp tables (do not use system statistic)", + &online_analyze_local_tracking, +#if PG_VERSION_NUM >= 80400 + online_analyze_local_tracking, +#endif + PGC_USERSET, +#if PG_VERSION_NUM >= 80400 + GUC_NOT_IN_SAMPLE, +#if PG_VERSION_NUM >= 90100 + NULL, +#endif +#endif + NULL, + NULL + ); + DefineCustomBoolVariable( "online_analyze.verbose", "Verbosity of on-line analyze",