2 * Copyright (c) 2011 Teodor Sigaev <teodor@sigaev.ru>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the author nor the names of any co-contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include "access/transam.h"
34 #include "catalog/namespace.h"
35 #include "commands/vacuum.h"
36 #include "executor/executor.h"
37 #include "nodes/nodes.h"
38 #include "nodes/parsenodes.h"
39 #include "storage/bufmgr.h"
40 #include "utils/builtins.h"
41 #include "utils/hsearch.h"
42 #include "utils/memutils.h"
43 #include "utils/lsyscache.h"
44 #include "utils/guc.h"
45 #if PG_VERSION_NUM >= 90200
46 #include "catalog/pg_class.h"
47 #include "nodes/primnodes.h"
48 #include "tcop/utility.h"
49 #include "utils/rel.h"
50 #include "utils/relcache.h"
51 #include "utils/timestamp.h"
52 #if PG_VERSION_NUM >= 90500
53 #include "nodes/makefuncs.h"
54 #if PG_VERSION_NUM >= 100000
55 #include "utils/varlena.h"
56 #include "utils/regproc.h"
61 #ifdef PG_MODULE_MAGIC
65 static bool online_analyze_enable = true;
66 static bool online_analyze_verbose = true;
67 static double online_analyze_scale_factor = 0.1;
68 static int online_analyze_threshold = 50;
69 static int online_analyze_capacity_threshold = 100000;
70 static double online_analyze_min_interval = 10000;
71 static int online_analyze_lower_limit = 0;
73 static ExecutorEnd_hook_type oldExecutorEndHook = NULL;
74 #if PG_VERSION_NUM >= 90200
75 static ProcessUtility_hook_type oldProcessUtilityHook = NULL;
80 CK_SELECT = CMD_SELECT,
81 CK_UPDATE = CMD_UPDATE,
82 CK_INSERT = CMD_INSERT,
83 CK_DELETE = CMD_DELETE,
95 OATT_PERSISTENT = 0x01,
96 OATT_TEMPORARY = 0x02,
98 } OnlineAnalyzeTableType;
100 static const struct config_enum_entry online_analyze_table_type_options[] =
102 {"all", OATT_ALL, false},
103 {"persistent", OATT_PERSISTENT, false},
104 {"temporary", OATT_TEMPORARY, false},
105 {"none", OATT_NONE, false},
109 static int online_analyze_table_type = (int)OATT_ALL;
111 typedef struct TableList {
117 static TableList excludeTables = {0, NULL, NULL};
118 static TableList includeTables = {0, NULL, NULL};
120 typedef struct OnlineAnalyzeTableStat {
123 PgStat_Counter n_tuples;
124 PgStat_Counter changes_since_analyze;
125 TimestampTz autovac_analyze_timestamp;
126 TimestampTz analyze_timestamp;
127 } OnlineAnalyzeTableStat;
129 static MemoryContext onlineAnalyzeMemoryContext = NULL;
130 static HTAB *relstats = NULL;
132 static void relstatsInit(void);
134 #if PG_VERSION_NUM < 100000
136 oid_cmp(const void *a, const void *b)
138 if (*(Oid*)a == *(Oid*)b)
140 return (*(Oid*)a > *(Oid*)b) ? 1 : -1;
145 tableListAssign(const char * newval, bool doit, TableList *tbl)
154 rawname = pstrdup(newval);
156 if (!SplitIdentifierString(rawname, ',', &namelist))
161 nOids = list_length(namelist);
162 newOids = malloc(sizeof(Oid) * (nOids+1));
164 elog(ERROR,"could not allocate %d bytes",
165 (int)(sizeof(Oid) * (nOids+1)));
170 char *curname = (char *) lfirst(l);
171 #if PG_VERSION_NUM >= 90200
172 Oid relOid = RangeVarGetRelid(makeRangeVarFromNameList(
173 stringToQualifiedNameList(curname)), NoLock, true);
175 Oid relOid = RangeVarGetRelid(makeRangeVarFromNameList(
176 stringToQualifiedNameList(curname)), true);
179 if (relOid == InvalidOid)
181 #if PG_VERSION_NUM >= 90100
184 elog(WARNING,"'%s' does not exist", curname);
187 else if ( get_rel_relkind(relOid) != RELKIND_RELATION )
189 #if PG_VERSION_NUM >= 90100
192 elog(WARNING,"'%s' is not an table", curname);
197 newOids[i++] = relOid;
206 tbl->tables = newOids;
207 if (tbl->nTables > 1)
208 qsort(tbl->tables, tbl->nTables, sizeof(tbl->tables[0]), oid_cmp);
224 #if PG_VERSION_NUM >= 90100
226 excludeTablesCheck(char **newval, void **extra, GucSource source)
230 val = (char*)tableListAssign(*newval, false, &excludeTables);
242 excludeTablesAssign(const char *newval, void *extra)
244 tableListAssign(newval, true, &excludeTables);
248 includeTablesCheck(char **newval, void **extra, GucSource source)
252 val = (char*)tableListAssign(*newval, false, &includeTables);
264 includeTablesAssign(const char *newval, void *extra)
266 tableListAssign(newval, true, &excludeTables);
269 #else /* PG_VERSION_NUM < 90100 */
272 excludeTablesAssign(const char * newval, bool doit, GucSource source)
274 return tableListAssign(newval, doit, &excludeTables);
278 includeTablesAssign(const char * newval, bool doit, GucSource source)
280 return tableListAssign(newval, doit, &includeTables);
286 tableListShow(TableList *tbl)
292 len = 1 /* \0 */ + tbl->nTables * (2 * NAMEDATALEN + 2 /* ', ' */ + 1 /* . */);
293 ptr = val = palloc(len);
295 for(i=0; i<tbl->nTables; i++)
297 char *relname = get_rel_name(tbl->tables[i]);
298 Oid nspOid = get_rel_namespace(tbl->tables[i]);
299 char *nspname = get_namespace_name(nspOid);
301 if ( relname == NULL || nspOid == InvalidOid || nspname == NULL )
304 ptr += snprintf(ptr, len - (ptr - val), "%s%s.%s",
313 excludeTablesShow(void)
315 return tableListShow(&excludeTables);
319 includeTablesShow(void)
321 return tableListShow(&includeTables);
325 matchOid(TableList *tbl, Oid oid)
327 Oid *StopLow = tbl->tables,
328 *StopHigh = tbl->tables + tbl->nTables,
331 /* Loop invariant: StopLow <= val < StopHigh */
332 while (StopLow < StopHigh)
334 StopMiddle = StopLow + ((StopHigh - StopLow) >> 1);
336 if (*StopMiddle == oid)
338 else if (*StopMiddle < oid)
339 StopLow = StopMiddle + 1;
341 StopHigh = StopMiddle;
347 #if PG_VERSION_NUM >= 90500
349 makeRangeVarFromOid(Oid relOid)
352 get_namespace_name(get_rel_namespace(relOid)),
353 get_rel_name(relOid),
361 makeAnalyze(Oid relOid, CmdKind operation, int64 naffected)
363 TimestampTz now = GetCurrentTimestamp();
365 OnlineAnalyzeTableType reltype;
368 OnlineAnalyzeTableStat *rstat,
370 PgStat_StatTabEntry *tabentry = NULL;
372 if (relOid == InvalidOid)
376 /* return if there is no changes */
378 else if (naffected < 0)
379 /* number if affected rows is unknown */
382 rel = RelationIdGetRelation(relOid);
383 if (rel->rd_rel->relkind != RELKIND_RELATION)
390 #if PG_VERSION_NUM >= 90100
391 (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
393 (rel->rd_istemp || rel->rd_islocaltemp)
395 ? OATT_TEMPORARY : OATT_PERSISTENT;
400 * includeTables overwrites excludeTables
402 switch(online_analyze_table_type)
405 if (get_rel_relkind(relOid) != RELKIND_RELATION ||
406 (matchOid(&excludeTables, relOid) == true &&
407 matchOid(&includeTables, relOid) == false))
411 if (get_rel_relkind(relOid) != RELKIND_RELATION ||
412 matchOid(&includeTables, relOid) == false)
416 case OATT_PERSISTENT:
419 * skip analyze if relation's type doesn't not match
420 * online_analyze_table_type
422 if ((online_analyze_table_type & reltype) == 0 ||
423 matchOid(&excludeTables, relOid) == true)
425 if (matchOid(&includeTables, relOid) == false)
432 * Do not store data about persistent table in local memory because we
433 * could not track changes of them: they could be changed by another
434 * backends. So always get a pgstat table entry.
436 if (reltype == OATT_TEMPORARY)
437 rstat = hash_search(relstats, &relOid, HASH_ENTER, &found);
439 rstat = &dummyrstat; /* found == false for following if */
443 MemSet(rstat, 0, sizeof(*rstat));
444 rstat->tableid = relOid;
447 else if (operation == CK_VACUUM)
449 /* force reread becouse vacuum could change n_tuples */
450 rstat->rereadStat = true;
453 else if (operation == CK_ANALYZE)
456 rstat->changes_since_analyze = 0;
460 Assert(rstat->tableid == relOid);
462 /* do not rered data if it was a truncation */
463 if (operation != CK_TRUNCATE && operation != CK_FASTTRUNCATE &&
464 (newTable == true || rstat->rereadStat == true))
466 rstat->rereadStat = false;
468 tabentry = pgstat_fetch_stat_tabentry(relOid);
472 rstat->n_tuples = tabentry->n_dead_tuples + tabentry->n_live_tuples;
473 rstat->changes_since_analyze =
474 #if PG_VERSION_NUM >= 90000
475 tabentry->changes_since_analyze;
477 tabentry->n_live_tuples + tabentry->n_dead_tuples -
478 tabentry->last_anl_tuples;
480 rstat->autovac_analyze_timestamp =
481 tabentry->autovac_analyze_timestamp;
482 rstat->analyze_timestamp = tabentry->analyze_timestamp;
487 /* force analyze after truncate, fasttruncate already did analyze */
488 operation == CK_TRUNCATE || (
489 /* do not analyze too often, if both stamps are exceeded the go */
490 TimestampDifferenceExceeds(rstat->analyze_timestamp, now, online_analyze_min_interval) &&
491 TimestampDifferenceExceeds(rstat->autovac_analyze_timestamp, now, online_analyze_min_interval) &&
492 /* do not analyze too small tables */
493 rstat->n_tuples + rstat->changes_since_analyze + naffected > online_analyze_lower_limit &&
494 /* be in sync with relation_needs_vacanalyze */
495 ((double)(rstat->changes_since_analyze + naffected)) >=
496 online_analyze_scale_factor * ((double)rstat->n_tuples) +
497 (double)online_analyze_threshold))
499 #if PG_VERSION_NUM < 90500
502 VacuumParams vacstmt;
504 TimestampTz startStamp, endStamp;
507 memset(&startStamp, 0, sizeof(startStamp)); /* keep compiler quiet */
509 memset(&vacstmt, 0, sizeof(vacstmt));
511 vacstmt.freeze_min_age = -1;
512 vacstmt.freeze_table_age = -1; /* ??? */
514 #if PG_VERSION_NUM < 90500
515 vacstmt.type = T_VacuumStmt;
516 vacstmt.relation = NULL;
517 vacstmt.va_cols = NIL;
518 #if PG_VERSION_NUM >= 90000
519 vacstmt.options = VACOPT_ANALYZE;
520 if (online_analyze_verbose)
521 vacstmt.options |= VACOPT_VERBOSE;
523 vacstmt.vacuum = vacstmt.full = false;
524 vacstmt.analyze = true;
525 vacstmt.verbose = online_analyze_verbose;
528 vacstmt.multixact_freeze_min_age = -1;
529 vacstmt.multixact_freeze_table_age = -1;
530 vacstmt.log_min_duration = -1;
533 if (online_analyze_verbose)
534 startStamp = GetCurrentTimestamp();
537 #if PG_VERSION_NUM < 90500
539 #if PG_VERSION_NUM >= 90018
542 , GetAccessStrategy(BAS_VACUUM)
543 #if (PG_VERSION_NUM >= 90000) && (PG_VERSION_NUM < 90004)
547 makeRangeVarFromOid(relOid),
548 VACOPT_ANALYZE | ((online_analyze_verbose) ? VACOPT_VERBOSE : 0),
549 &vacstmt, NULL, true, GetAccessStrategy(BAS_VACUUM)
553 if (online_analyze_verbose)
558 endStamp = GetCurrentTimestamp();
559 TimestampDifference(startStamp, endStamp, &secs, µsecs);
560 elog(INFO, "analyze \"%s\" took %.02f seconds",
561 get_rel_name(relOid),
562 ((double)secs) + ((double)microsecs)/1.0e6);
565 rstat->autovac_analyze_timestamp = now;
566 rstat->changes_since_analyze = 0;
573 rstat->n_tuples += naffected;
575 rstat->rereadStat = (reltype == OATT_PERSISTENT);
578 case CK_FASTTRUNCATE:
579 rstat->rereadStat = false;
586 /* update last analyze timestamp in local memory of backend */
589 tabentry->analyze_timestamp = now;
590 tabentry->changes_since_analyze = 0;
593 /* force reload stat for new table */
595 pgstat_clear_snapshot();
600 #if PG_VERSION_NUM >= 90000
602 tabentry->changes_since_analyze += naffected;
608 rstat->changes_since_analyze += naffected;
609 rstat->n_tuples += naffected;
612 rstat->changes_since_analyze += 2 * naffected;
613 rstat->n_tuples += naffected;
615 rstat->changes_since_analyze += naffected;
618 case CK_FASTTRUNCATE:
619 rstat->changes_since_analyze = 0;
627 /* Reset local cache if we are over limit */
628 if (hash_get_num_entries(relstats) > online_analyze_capacity_threshold)
633 isFastTruncateCall(QueryDesc *queryDesc)
640 queryDesc->plannedstmt &&
641 queryDesc->operation == CMD_SELECT &&
642 queryDesc->plannedstmt->planTree &&
643 queryDesc->plannedstmt->planTree->targetlist &&
644 list_length(queryDesc->plannedstmt->planTree->targetlist) == 1 &&
645 IsA(linitial(queryDesc->plannedstmt->planTree->targetlist), TargetEntry)
649 te = linitial(queryDesc->plannedstmt->planTree->targetlist);
651 if (!IsA(te, TargetEntry))
654 fe = (FuncExpr*)te->expr;
657 fe && IsA(fe, FuncExpr) &&
658 fe->funcid >= FirstNormalObjectId &&
659 fe->funcretset == false &&
660 fe->funcresulttype == VOIDOID &&
661 fe->funcvariadic == false &&
662 list_length(fe->args) == 1 &&
663 IsA(linitial(fe->args), Const)
667 constval = linitial(fe->args);
670 IsA(constval,Const) &&
671 constval->consttype == TEXTOID &&
672 strcmp(get_func_name(fe->funcid), "fasttruncate") == 0
681 extern PGDLLIMPORT void onlineAnalyzeHooker(QueryDesc *queryDesc);
683 onlineAnalyzeHooker(QueryDesc *queryDesc)
685 int64 naffected = -1;
688 if (queryDesc->estate)
689 naffected = queryDesc->estate->es_processed;
691 #if PG_VERSION_NUM >= 90200
692 if (online_analyze_enable &&
693 (constval = isFastTruncateCall(queryDesc)) != NULL)
695 Datum tblnamed = constval->constvalue;
696 char *tblname = text_to_cstring(DatumGetTextP(tblnamed));
698 makeRangeVarFromNameList(stringToQualifiedNameList(tblname));
700 makeAnalyze(RangeVarGetRelid(tblvar,
703 CK_FASTTRUNCATE, -1);
707 if (online_analyze_enable && queryDesc->plannedstmt &&
708 (queryDesc->operation == CMD_INSERT ||
709 queryDesc->operation == CMD_UPDATE ||
710 queryDesc->operation == CMD_DELETE
711 #if PG_VERSION_NUM < 90200
712 || (queryDesc->operation == CMD_SELECT &&
713 queryDesc->plannedstmt->intoClause)
717 #if PG_VERSION_NUM < 90200
718 if (queryDesc->operation == CMD_SELECT)
720 Oid relOid = RangeVarGetRelid(queryDesc->plannedstmt->intoClause->rel, true);
722 makeAnalyze(relOid, queryDesc->operation, naffected);
726 if (queryDesc->plannedstmt->resultRelations &&
727 queryDesc->plannedstmt->rtable)
731 foreach(l, queryDesc->plannedstmt->resultRelations)
733 int n = lfirst_int(l);
734 RangeTblEntry *rte = list_nth(queryDesc->plannedstmt->rtable, n-1);
736 if (rte->rtekind == RTE_RELATION)
737 makeAnalyze(rte->relid, (CmdKind)queryDesc->operation, naffected);
742 if (oldExecutorEndHook)
743 oldExecutorEndHook(queryDesc);
745 standard_ExecutorEnd(queryDesc);
748 #if PG_VERSION_NUM >= 90200
750 onlineAnalyzeHookerUtility(
751 #if PG_VERSION_NUM >= 100000
756 const char *queryString,
757 #if PG_VERSION_NUM >= 90300
758 ProcessUtilityContext context, ParamListInfo params,
759 #if PG_VERSION_NUM >= 100000
760 QueryEnvironment *queryEnv,
763 ParamListInfo params, bool isTopLevel,
765 DestReceiver *dest, char *completionTag) {
766 List *tblnames = NIL;
767 CmdKind op = CK_INSERT;
768 #if PG_VERSION_NUM >= 100000
769 Node *parsetree = NULL;
771 if (pstmt->commandType == CMD_UTILITY)
772 parsetree = pstmt->utilityStmt;
775 if (parsetree && online_analyze_enable)
777 if (IsA(parsetree, CreateTableAsStmt) &&
778 ((CreateTableAsStmt*)parsetree)->into)
781 list_make1((RangeVar*)copyObject(((CreateTableAsStmt*)parsetree)->into->rel));
784 else if (IsA(parsetree, TruncateStmt))
786 tblnames = list_copy(((TruncateStmt*)parsetree)->relations);
789 else if (IsA(parsetree, VacuumStmt))
791 VacuumStmt *vac = (VacuumStmt*)parsetree;
793 tblnames = list_make1(vac->relation);
795 if (vac->options & (VACOPT_VACUUM | VACOPT_FULL | VACOPT_FREEZE))
796 /* optionally with analyze */
798 else if (vac->options & VACOPT_ANALYZE)
805 #if PG_VERSION_NUM >= 100000
806 #define parsetree pstmt
809 if (oldProcessUtilityHook)
810 oldProcessUtilityHook(parsetree, queryString,
811 #if PG_VERSION_NUM >= 90300
813 #if PG_VERSION_NUM >= 100000
819 dest, completionTag);
821 standard_ProcessUtility(parsetree, queryString,
822 #if PG_VERSION_NUM >= 90300
824 #if PG_VERSION_NUM >= 100000
830 dest, completionTag);
832 #if PG_VERSION_NUM >= 100000
841 RangeVar *tblname = (RangeVar*)lfirst(l);
842 Oid tblOid = RangeVarGetRelid(tblname, NoLock, true);
844 makeAnalyze(tblOid, op, -1);
856 MemSet(&hash_ctl, 0, sizeof(hash_ctl));
858 hash_ctl.hash = oid_hash;
859 flags |= HASH_FUNCTION;
861 if (onlineAnalyzeMemoryContext)
863 Assert(relstats != NULL);
864 MemoryContextReset(onlineAnalyzeMemoryContext);
868 Assert(relstats == NULL);
869 onlineAnalyzeMemoryContext =
870 AllocSetContextCreate(CacheMemoryContext,
871 "online_analyze storage context",
872 #if PG_VERSION_NUM < 90600
873 ALLOCSET_DEFAULT_MINSIZE,
874 ALLOCSET_DEFAULT_INITSIZE,
875 ALLOCSET_DEFAULT_MAXSIZE
877 ALLOCSET_DEFAULT_SIZES
882 hash_ctl.hcxt = onlineAnalyzeMemoryContext;
883 flags |= HASH_CONTEXT;
885 hash_ctl.keysize = sizeof(Oid);
887 hash_ctl.entrysize = sizeof(OnlineAnalyzeTableStat);
890 relstats = hash_create("online_analyze storage", 1024, &hash_ctl, flags);
899 oldExecutorEndHook = ExecutorEnd_hook;
901 ExecutorEnd_hook = onlineAnalyzeHooker;
903 #if PG_VERSION_NUM >= 90200
904 oldProcessUtilityHook = ProcessUtility_hook;
906 ProcessUtility_hook = onlineAnalyzeHookerUtility;
910 DefineCustomBoolVariable(
911 "online_analyze.enable",
912 "Enable on-line analyze",
913 "Enables analyze of table directly after insert/update/delete/select into",
914 &online_analyze_enable,
915 #if PG_VERSION_NUM >= 80400
916 online_analyze_enable,
919 #if PG_VERSION_NUM >= 80400
921 #if PG_VERSION_NUM >= 90100
929 DefineCustomBoolVariable(
930 "online_analyze.verbose",
931 "Verbosity of on-line analyze",
932 "Make ANALYZE VERBOSE after table's changes",
933 &online_analyze_verbose,
934 #if PG_VERSION_NUM >= 80400
935 online_analyze_verbose,
938 #if PG_VERSION_NUM >= 80400
940 #if PG_VERSION_NUM >= 90100
948 DefineCustomRealVariable(
949 "online_analyze.scale_factor",
950 "fraction of table size to start on-line analyze",
951 "fraction of table size to start on-line analyze",
952 &online_analyze_scale_factor,
953 #if PG_VERSION_NUM >= 80400
954 online_analyze_scale_factor,
959 #if PG_VERSION_NUM >= 80400
961 #if PG_VERSION_NUM >= 90100
969 DefineCustomIntVariable(
970 "online_analyze.threshold",
971 "min number of row updates before on-line analyze",
972 "min number of row updates before on-line analyze",
973 &online_analyze_threshold,
974 #if PG_VERSION_NUM >= 80400
975 online_analyze_threshold,
980 #if PG_VERSION_NUM >= 80400
982 #if PG_VERSION_NUM >= 90100
990 DefineCustomIntVariable(
991 "online_analyze.capacity_threshold",
992 "Max local cache table capacity",
993 "Max local cache table capacity",
994 &online_analyze_capacity_threshold,
995 #if PG_VERSION_NUM >= 80400
996 online_analyze_capacity_threshold,
1001 #if PG_VERSION_NUM >= 80400
1003 #if PG_VERSION_NUM >= 90100
1011 DefineCustomRealVariable(
1012 "online_analyze.min_interval",
1013 "minimum time interval between analyze call (in milliseconds)",
1014 "minimum time interval between analyze call (in milliseconds)",
1015 &online_analyze_min_interval,
1016 #if PG_VERSION_NUM >= 80400
1017 online_analyze_min_interval,
1022 #if PG_VERSION_NUM >= 80400
1024 #if PG_VERSION_NUM >= 90100
1032 DefineCustomEnumVariable(
1033 "online_analyze.table_type",
1034 "Type(s) of table for online analyze: all(default), persistent, temporary, none",
1036 &online_analyze_table_type,
1037 #if PG_VERSION_NUM >= 80400
1038 online_analyze_table_type,
1040 online_analyze_table_type_options,
1042 #if PG_VERSION_NUM >= 80400
1044 #if PG_VERSION_NUM >= 90100
1052 DefineCustomStringVariable(
1053 "online_analyze.exclude_tables",
1054 "List of tables which will not online analyze",
1056 &excludeTables.tableStr,
1057 #if PG_VERSION_NUM >= 80400
1062 #if PG_VERSION_NUM >= 90100
1064 excludeTablesAssign,
1066 excludeTablesAssign,
1071 DefineCustomStringVariable(
1072 "online_analyze.include_tables",
1073 "List of tables which will online analyze",
1075 &includeTables.tableStr,
1076 #if PG_VERSION_NUM >= 80400
1081 #if PG_VERSION_NUM >= 90100
1083 includeTablesAssign,
1085 includeTablesAssign,
1090 DefineCustomIntVariable(
1091 "online_analyze.lower_limit",
1092 "min number of rows in table to analyze",
1093 "min number of rows in table to analyze",
1094 &online_analyze_lower_limit,
1095 #if PG_VERSION_NUM >= 80400
1096 online_analyze_lower_limit,
1101 #if PG_VERSION_NUM >= 80400
1103 #if PG_VERSION_NUM >= 90100
1113 void _PG_fini(void);
1117 ExecutorEnd_hook = oldExecutorEndHook;
1118 #if PG_VERSION_NUM >= 90200
1119 ProcessUtility_hook = oldProcessUtilityHook;
1122 if (excludeTables.tables)
1123 free(excludeTables.tables);
1124 if (includeTables.tables)
1125 free(includeTables.tables);
1127 excludeTables.tables = includeTables.tables = NULL;
1128 excludeTables.nTables = includeTables.nTables = 0;