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,
93 OATT_PERSISTENT = 0x01,
94 OATT_TEMPORARY = 0x02,
96 } OnlineAnalyzeTableType;
98 static const struct config_enum_entry online_analyze_table_type_options[] =
100 {"all", OATT_ALL, false},
101 {"persistent", OATT_PERSISTENT, false},
102 {"temporary", OATT_TEMPORARY, false},
103 {"none", OATT_NONE, false},
107 static int online_analyze_table_type = (int)OATT_ALL;
109 typedef struct TableList {
115 static TableList excludeTables = {0, NULL, NULL};
116 static TableList includeTables = {0, NULL, NULL};
118 typedef struct OnlineAnalyzeTableStat {
121 PgStat_Counter n_tuples;
122 PgStat_Counter changes_since_analyze;
123 TimestampTz autovac_analyze_timestamp;
124 TimestampTz analyze_timestamp;
125 } OnlineAnalyzeTableStat;
127 static MemoryContext onlineAnalyzeMemoryContext = NULL;
128 static HTAB *relstats = NULL;
130 static void relstatsInit(void);
132 #if PG_VERSION_NUM < 100000
134 oid_cmp(const void *a, const void *b)
136 if (*(Oid*)a == *(Oid*)b)
138 return (*(Oid*)a > *(Oid*)b) ? 1 : -1;
143 tableListAssign(const char * newval, bool doit, TableList *tbl)
152 rawname = pstrdup(newval);
154 if (!SplitIdentifierString(rawname, ',', &namelist))
159 nOids = list_length(namelist);
160 newOids = malloc(sizeof(Oid) * (nOids+1));
162 elog(ERROR,"could not allocate %d bytes",
163 (int)(sizeof(Oid) * (nOids+1)));
168 char *curname = (char *) lfirst(l);
169 #if PG_VERSION_NUM >= 90200
170 Oid relOid = RangeVarGetRelid(makeRangeVarFromNameList(
171 stringToQualifiedNameList(curname)), NoLock, true);
173 Oid relOid = RangeVarGetRelid(makeRangeVarFromNameList(
174 stringToQualifiedNameList(curname)), true);
177 if (relOid == InvalidOid)
179 #if PG_VERSION_NUM >= 90100
182 elog(WARNING,"'%s' does not exist", curname);
185 else if ( get_rel_relkind(relOid) != RELKIND_RELATION )
187 #if PG_VERSION_NUM >= 90100
190 elog(WARNING,"'%s' is not an table", curname);
195 newOids[i++] = relOid;
204 tbl->tables = newOids;
205 if (tbl->nTables > 1)
206 qsort(tbl->tables, tbl->nTables, sizeof(tbl->tables[0]), oid_cmp);
222 #if PG_VERSION_NUM >= 90100
224 excludeTablesCheck(char **newval, void **extra, GucSource source)
228 val = (char*)tableListAssign(*newval, false, &excludeTables);
240 excludeTablesAssign(const char *newval, void *extra)
242 tableListAssign(newval, true, &excludeTables);
246 includeTablesCheck(char **newval, void **extra, GucSource source)
250 val = (char*)tableListAssign(*newval, false, &includeTables);
262 includeTablesAssign(const char *newval, void *extra)
264 tableListAssign(newval, true, &excludeTables);
267 #else /* PG_VERSION_NUM < 90100 */
270 excludeTablesAssign(const char * newval, bool doit, GucSource source)
272 return tableListAssign(newval, doit, &excludeTables);
276 includeTablesAssign(const char * newval, bool doit, GucSource source)
278 return tableListAssign(newval, doit, &includeTables);
284 tableListShow(TableList *tbl)
290 len = 1 /* \0 */ + tbl->nTables * (2 * NAMEDATALEN + 2 /* ', ' */ + 1 /* . */);
291 ptr = val = palloc(len);
293 for(i=0; i<tbl->nTables; i++)
295 char *relname = get_rel_name(tbl->tables[i]);
296 Oid nspOid = get_rel_namespace(tbl->tables[i]);
297 char *nspname = get_namespace_name(nspOid);
299 if ( relname == NULL || nspOid == InvalidOid || nspname == NULL )
302 ptr += snprintf(ptr, len - (ptr - val), "%s%s.%s",
311 excludeTablesShow(void)
313 return tableListShow(&excludeTables);
317 includeTablesShow(void)
319 return tableListShow(&includeTables);
323 matchOid(TableList *tbl, Oid oid)
325 Oid *StopLow = tbl->tables,
326 *StopHigh = tbl->tables + tbl->nTables,
329 /* Loop invariant: StopLow <= val < StopHigh */
330 while (StopLow < StopHigh)
332 StopMiddle = StopLow + ((StopHigh - StopLow) >> 1);
334 if (*StopMiddle == oid)
336 else if (*StopMiddle < oid)
337 StopLow = StopMiddle + 1;
339 StopHigh = StopMiddle;
345 #if PG_VERSION_NUM >= 90500
347 makeRangeVarFromOid(Oid relOid)
350 get_namespace_name(get_rel_namespace(relOid)),
351 get_rel_name(relOid),
359 makeAnalyze(Oid relOid, CmdKind operation, int64 naffected)
361 TimestampTz now = GetCurrentTimestamp();
363 OnlineAnalyzeTableType reltype;
366 OnlineAnalyzeTableStat *rstat,
368 PgStat_StatTabEntry *tabentry = NULL;
370 if (relOid == InvalidOid)
373 elog(NOTICE,"makeAnalyze operation: %d naffected: %d",
374 operation, (int32)naffected);
377 /* return if there is no changes */
379 else if (naffected < 0)
380 /* number if affected rows is unknown */
383 rel = RelationIdGetRelation(relOid);
384 if (rel->rd_rel->relkind != RELKIND_RELATION)
391 #if PG_VERSION_NUM >= 90100
392 (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
394 (rel->rd_istemp || rel->rd_islocaltemp)
396 ? OATT_TEMPORARY : OATT_PERSISTENT;
401 * includeTables overwrites excludeTables
403 switch(online_analyze_table_type)
406 if (get_rel_relkind(relOid) != RELKIND_RELATION ||
407 (matchOid(&excludeTables, relOid) == true &&
408 matchOid(&includeTables, relOid) == false))
412 if (get_rel_relkind(relOid) != RELKIND_RELATION ||
413 matchOid(&includeTables, relOid) == false)
417 case OATT_PERSISTENT:
420 * skip analyze if relation's type doesn't not match
421 * online_analyze_table_type
423 if ((online_analyze_table_type & reltype) == 0 ||
424 matchOid(&excludeTables, relOid) == true)
426 if (matchOid(&includeTables, relOid) == false)
433 * Do not store data about persistent table in local memory because we
434 * could not track changes of them: they could be changed by another
435 * backends. So always get a pgstat table entry.
437 if (reltype == OATT_TEMPORARY)
438 rstat = hash_search(relstats, &relOid, HASH_ENTER, &found);
440 rstat = &dummyrstat; /* found == false for following if */
444 MemSet(rstat, 0, sizeof(*rstat));
445 rstat->tableid = relOid;
449 Assert(rstat->tableid == relOid);
451 /* do not rered data if it was a truncation */
452 if (operation != CK_TRUNCATE && operation != CK_FASTTRUNCATE &&
453 (newTable == true || rstat->rereadStat == true))
455 rstat->rereadStat = false;
457 tabentry = pgstat_fetch_stat_tabentry(relOid);
461 rstat->n_tuples = tabentry->n_dead_tuples + tabentry->n_live_tuples;
462 rstat->changes_since_analyze =
463 #if PG_VERSION_NUM >= 90000
464 tabentry->changes_since_analyze;
466 tabentry->n_live_tuples + tabentry->n_dead_tuples -
467 tabentry->last_anl_tuples;
469 rstat->autovac_analyze_timestamp =
470 tabentry->autovac_analyze_timestamp;
471 rstat->analyze_timestamp = tabentry->analyze_timestamp;
476 /* force analyze after truncate, fasttruncate already did analyze */
477 operation == CK_TRUNCATE || (
478 /* do not analyze too often, if both stamps are exceeded the go */
479 TimestampDifferenceExceeds(rstat->analyze_timestamp, now, online_analyze_min_interval) &&
480 TimestampDifferenceExceeds(rstat->autovac_analyze_timestamp, now, online_analyze_min_interval) &&
481 /* do not analyze too small tables */
482 rstat->n_tuples + rstat->changes_since_analyze + naffected > online_analyze_lower_limit &&
483 /* be in sync with relation_needs_vacanalyze */
484 ((double)(rstat->changes_since_analyze + naffected)) >=
485 online_analyze_scale_factor * ((double)rstat->n_tuples) +
486 (double)online_analyze_threshold))
488 #if PG_VERSION_NUM < 90500
491 VacuumParams vacstmt;
493 TimestampTz startStamp, endStamp;
496 memset(&startStamp, 0, sizeof(startStamp)); /* keep compiler quiet */
498 memset(&vacstmt, 0, sizeof(vacstmt));
500 vacstmt.freeze_min_age = -1;
501 vacstmt.freeze_table_age = -1; /* ??? */
503 #if PG_VERSION_NUM < 90500
504 vacstmt.type = T_VacuumStmt;
505 vacstmt.relation = NULL;
506 vacstmt.va_cols = NIL;
507 #if PG_VERSION_NUM >= 90000
508 vacstmt.options = VACOPT_ANALYZE;
509 if (online_analyze_verbose)
510 vacstmt.options |= VACOPT_VERBOSE;
512 vacstmt.vacuum = vacstmt.full = false;
513 vacstmt.analyze = true;
514 vacstmt.verbose = online_analyze_verbose;
517 vacstmt.multixact_freeze_min_age = -1;
518 vacstmt.multixact_freeze_table_age = -1;
519 vacstmt.log_min_duration = -1;
522 if (online_analyze_verbose)
523 startStamp = GetCurrentTimestamp();
526 #if PG_VERSION_NUM < 90500
528 #if PG_VERSION_NUM >= 90018
531 , GetAccessStrategy(BAS_VACUUM)
532 #if (PG_VERSION_NUM >= 90000) && (PG_VERSION_NUM < 90004)
536 makeRangeVarFromOid(relOid),
537 VACOPT_ANALYZE | ((online_analyze_verbose) ? VACOPT_VERBOSE : 0),
538 &vacstmt, NULL, true, GetAccessStrategy(BAS_VACUUM)
542 if (online_analyze_verbose)
547 endStamp = GetCurrentTimestamp();
548 TimestampDifference(startStamp, endStamp, &secs, µsecs);
549 elog(INFO, "analyze \"%s\" took %.02f seconds",
550 get_rel_name(relOid),
551 ((double)secs) + ((double)microsecs)/1.0e6);
554 rstat->autovac_analyze_timestamp = now;
555 rstat->changes_since_analyze = 0;
562 rstat->n_tuples += naffected;
564 rstat->rereadStat = (reltype == OATT_PERSISTENT);
567 case CK_FASTTRUNCATE:
574 /* update last analyze timestamp in local memory of backend */
577 tabentry->analyze_timestamp = now;
578 tabentry->changes_since_analyze = 0;
581 /* force reload stat for new table */
583 pgstat_clear_snapshot();
588 #if PG_VERSION_NUM >= 90000
590 tabentry->changes_since_analyze += naffected;
596 rstat->changes_since_analyze += naffected;
597 rstat->n_tuples += naffected;
600 rstat->changes_since_analyze += 2 * naffected;
601 rstat->n_tuples += naffected;
603 rstat->changes_since_analyze += naffected;
606 case CK_FASTTRUNCATE:
607 rstat->changes_since_analyze = 0;
615 /* Reset local cache if we are over limit */
616 if (hash_get_num_entries(relstats) > online_analyze_capacity_threshold)
621 isFastTruncateCall(QueryDesc *queryDesc)
628 queryDesc->plannedstmt &&
629 queryDesc->operation == CMD_SELECT &&
630 queryDesc->plannedstmt->planTree &&
631 queryDesc->plannedstmt->planTree->targetlist &&
632 list_length(queryDesc->plannedstmt->planTree->targetlist) == 1 &&
633 IsA(linitial(queryDesc->plannedstmt->planTree->targetlist), TargetEntry)
637 te = linitial(queryDesc->plannedstmt->planTree->targetlist);
639 if (!IsA(te, TargetEntry))
642 fe = (FuncExpr*)te->expr;
645 fe && IsA(fe, FuncExpr) &&
646 fe->funcid >= FirstNormalObjectId &&
647 fe->funcretset == false &&
648 fe->funcresulttype == VOIDOID &&
649 fe->funcvariadic == false &&
650 list_length(fe->args) == 1 &&
651 IsA(linitial(fe->args), Const)
655 constval = linitial(fe->args);
658 IsA(constval,Const) &&
659 constval->consttype == TEXTOID &&
660 strcmp(get_func_name(fe->funcid), "fasttruncate") == 0
669 extern PGDLLIMPORT void onlineAnalyzeHooker(QueryDesc *queryDesc);
671 onlineAnalyzeHooker(QueryDesc *queryDesc)
673 int64 naffected = -1;
676 if (queryDesc->estate)
677 naffected = queryDesc->estate->es_processed;
679 #if PG_VERSION_NUM >= 90200
680 if (online_analyze_enable &&
681 (constval = isFastTruncateCall(queryDesc)) != NULL)
683 Datum tblnamed = constval->constvalue;
684 char *tblname = text_to_cstring(DatumGetTextP(tblnamed));
686 makeRangeVarFromNameList(stringToQualifiedNameList(tblname));
688 makeAnalyze(RangeVarGetRelid(tblvar,
691 CK_FASTTRUNCATE, -1);
695 if (online_analyze_enable && queryDesc->plannedstmt &&
696 (queryDesc->operation == CMD_INSERT ||
697 queryDesc->operation == CMD_UPDATE ||
698 queryDesc->operation == CMD_DELETE
699 #if PG_VERSION_NUM < 90200
700 || (queryDesc->operation == CMD_SELECT &&
701 queryDesc->plannedstmt->intoClause)
705 #if PG_VERSION_NUM < 90200
706 if (queryDesc->operation == CMD_SELECT)
708 Oid relOid = RangeVarGetRelid(queryDesc->plannedstmt->intoClause->rel, true);
710 makeAnalyze(relOid, queryDesc->operation, naffected);
714 if (queryDesc->plannedstmt->resultRelations &&
715 queryDesc->plannedstmt->rtable)
719 foreach(l, queryDesc->plannedstmt->resultRelations)
721 int n = lfirst_int(l);
722 RangeTblEntry *rte = list_nth(queryDesc->plannedstmt->rtable, n-1);
724 if (rte->rtekind == RTE_RELATION)
725 makeAnalyze(rte->relid, (CmdKind)queryDesc->operation, naffected);
730 if (oldExecutorEndHook)
731 oldExecutorEndHook(queryDesc);
733 standard_ExecutorEnd(queryDesc);
736 #if PG_VERSION_NUM >= 90200
738 onlineAnalyzeHookerUtility(
739 #if PG_VERSION_NUM >= 100000
744 const char *queryString,
745 #if PG_VERSION_NUM >= 90300
746 ProcessUtilityContext context, ParamListInfo params,
747 #if PG_VERSION_NUM >= 100000
748 QueryEnvironment *queryEnv,
751 ParamListInfo params, bool isTopLevel,
753 DestReceiver *dest, char *completionTag) {
754 List *tblnames = NIL;
755 CmdKind op = CK_INSERT;
756 #if PG_VERSION_NUM >= 100000
757 Node *parsetree = NULL;
759 if (pstmt->commandType == CMD_UTILITY)
760 parsetree = pstmt->utilityStmt;
763 if (parsetree && online_analyze_enable)
765 if (IsA(parsetree, CreateTableAsStmt) &&
766 ((CreateTableAsStmt*)parsetree)->into)
769 list_make1((RangeVar*)copyObject(((CreateTableAsStmt*)parsetree)->into->rel));
772 else if (IsA(parsetree, TruncateStmt))
774 tblnames = list_copy(((TruncateStmt*)parsetree)->relations);
779 #if PG_VERSION_NUM >= 100000
780 #define parsetree pstmt
783 if (oldProcessUtilityHook)
784 oldProcessUtilityHook(parsetree, queryString,
785 #if PG_VERSION_NUM >= 90300
787 #if PG_VERSION_NUM >= 100000
793 dest, completionTag);
795 standard_ProcessUtility(parsetree, queryString,
796 #if PG_VERSION_NUM >= 90300
798 #if PG_VERSION_NUM >= 100000
804 dest, completionTag);
806 #if PG_VERSION_NUM >= 100000
815 RangeVar *tblname = (RangeVar*)lfirst(l);
816 Oid tblOid = RangeVarGetRelid(tblname, NoLock, true);
818 makeAnalyze(tblOid, op, -1);
830 MemSet(&hash_ctl, 0, sizeof(hash_ctl));
832 hash_ctl.hash = oid_hash;
833 flags |= HASH_FUNCTION;
835 if (onlineAnalyzeMemoryContext)
837 Assert(relstats != NULL);
838 MemoryContextReset(onlineAnalyzeMemoryContext);
842 Assert(relstats == NULL);
843 onlineAnalyzeMemoryContext =
844 AllocSetContextCreate(CacheMemoryContext,
845 "online_analyze storage context",
846 #if PG_VERSION_NUM < 90600
847 ALLOCSET_DEFAULT_MINSIZE,
848 ALLOCSET_DEFAULT_INITSIZE,
849 ALLOCSET_DEFAULT_MAXSIZE
851 ALLOCSET_DEFAULT_SIZES
856 hash_ctl.hcxt = onlineAnalyzeMemoryContext;
857 flags |= HASH_CONTEXT;
859 hash_ctl.keysize = sizeof(Oid);
861 hash_ctl.entrysize = sizeof(OnlineAnalyzeTableStat);
864 relstats = hash_create("online_analyze storage", 1024, &hash_ctl, flags);
873 oldExecutorEndHook = ExecutorEnd_hook;
875 ExecutorEnd_hook = onlineAnalyzeHooker;
877 #if PG_VERSION_NUM >= 90200
878 oldProcessUtilityHook = ProcessUtility_hook;
880 ProcessUtility_hook = onlineAnalyzeHookerUtility;
884 DefineCustomBoolVariable(
885 "online_analyze.enable",
886 "Enable on-line analyze",
887 "Enables analyze of table directly after insert/update/delete/select into",
888 &online_analyze_enable,
889 #if PG_VERSION_NUM >= 80400
890 online_analyze_enable,
893 #if PG_VERSION_NUM >= 80400
895 #if PG_VERSION_NUM >= 90100
903 DefineCustomBoolVariable(
904 "online_analyze.verbose",
905 "Verbosity of on-line analyze",
906 "Make ANALYZE VERBOSE after table's changes",
907 &online_analyze_verbose,
908 #if PG_VERSION_NUM >= 80400
909 online_analyze_verbose,
912 #if PG_VERSION_NUM >= 80400
914 #if PG_VERSION_NUM >= 90100
922 DefineCustomRealVariable(
923 "online_analyze.scale_factor",
924 "fraction of table size to start on-line analyze",
925 "fraction of table size to start on-line analyze",
926 &online_analyze_scale_factor,
927 #if PG_VERSION_NUM >= 80400
928 online_analyze_scale_factor,
933 #if PG_VERSION_NUM >= 80400
935 #if PG_VERSION_NUM >= 90100
943 DefineCustomIntVariable(
944 "online_analyze.threshold",
945 "min number of row updates before on-line analyze",
946 "min number of row updates before on-line analyze",
947 &online_analyze_threshold,
948 #if PG_VERSION_NUM >= 80400
949 online_analyze_threshold,
954 #if PG_VERSION_NUM >= 80400
956 #if PG_VERSION_NUM >= 90100
964 DefineCustomIntVariable(
965 "online_analyze.capacity_threshold",
966 "Max local cache table capacity",
967 "Max local cache table capacity",
968 &online_analyze_capacity_threshold,
969 #if PG_VERSION_NUM >= 80400
970 online_analyze_capacity_threshold,
975 #if PG_VERSION_NUM >= 80400
977 #if PG_VERSION_NUM >= 90100
985 DefineCustomRealVariable(
986 "online_analyze.min_interval",
987 "minimum time interval between analyze call (in milliseconds)",
988 "minimum time interval between analyze call (in milliseconds)",
989 &online_analyze_min_interval,
990 #if PG_VERSION_NUM >= 80400
991 online_analyze_min_interval,
996 #if PG_VERSION_NUM >= 80400
998 #if PG_VERSION_NUM >= 90100
1006 DefineCustomEnumVariable(
1007 "online_analyze.table_type",
1008 "Type(s) of table for online analyze: all(default), persistent, temporary, none",
1010 &online_analyze_table_type,
1011 #if PG_VERSION_NUM >= 80400
1012 online_analyze_table_type,
1014 online_analyze_table_type_options,
1016 #if PG_VERSION_NUM >= 80400
1018 #if PG_VERSION_NUM >= 90100
1026 DefineCustomStringVariable(
1027 "online_analyze.exclude_tables",
1028 "List of tables which will not online analyze",
1030 &excludeTables.tableStr,
1031 #if PG_VERSION_NUM >= 80400
1036 #if PG_VERSION_NUM >= 90100
1038 excludeTablesAssign,
1040 excludeTablesAssign,
1045 DefineCustomStringVariable(
1046 "online_analyze.include_tables",
1047 "List of tables which will online analyze",
1049 &includeTables.tableStr,
1050 #if PG_VERSION_NUM >= 80400
1055 #if PG_VERSION_NUM >= 90100
1057 includeTablesAssign,
1059 includeTablesAssign,
1064 DefineCustomIntVariable(
1065 "online_analyze.lower_limit",
1066 "min number of rows in table to analyze",
1067 "min number of rows in table to analyze",
1068 &online_analyze_lower_limit,
1069 #if PG_VERSION_NUM >= 80400
1070 online_analyze_lower_limit,
1075 #if PG_VERSION_NUM >= 80400
1077 #if PG_VERSION_NUM >= 90100
1087 void _PG_fini(void);
1091 ExecutorEnd_hook = oldExecutorEndHook;
1092 #if PG_VERSION_NUM >= 90200
1093 ProcessUtility_hook = oldProcessUtilityHook;
1096 if (excludeTables.tables)
1097 free(excludeTables.tables);
1098 if (includeTables.tables)
1099 free(includeTables.tables);
1101 excludeTables.tables = includeTables.tables = NULL;
1102 excludeTables.nTables = includeTables.nTables = 0;