60 #include "utils/fmgroids.h"
93 bool inh,
bool in_outer_xact,
int elevel);
102 double *totalrows,
double *totaldeadrows);
106 double *totalrows,
double *totaldeadrows);
200 if (onerel->
rd_rel->relkind == RELKIND_RELATION ||
201 onerel->
rd_rel->relkind == RELKIND_MATVIEW)
208 else if (onerel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
227 (
errmsg(
"skipping \"%s\" --- cannot analyze this foreign table",
233 else if (onerel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
244 (
errmsg(
"skipping \"%s\" --- cannot analyze non-tables or special system tables",
260 if (onerel->
rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
262 relpages,
false, in_outer_xact, elevel);
267 if (onerel->
rd_rel->relhassubclass)
269 true, in_outer_xact, elevel);
292 BlockNumber relpages,
bool inh,
bool in_outer_xact,
314 int save_sec_context;
324 (
errmsg(
"analyzing \"%s.%s\" inheritance tree",
329 (
errmsg(
"analyzing \"%s.%s\"",
388 (
errcode(ERRCODE_UNDEFINED_COLUMN),
389 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
393 (
errcode(ERRCODE_DUPLICATE_COLUMN),
394 errmsg(
"column \"%s\" of relation \"%s\" appears more than once",
399 if (vacattrstats[tcnt] != NULL)
410 for (
i = 1;
i <= attr_cnt;
i++)
413 if (vacattrstats[tcnt] != NULL)
428 if (onerel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
434 hasindex = idxs !=
NIL;
440 hasindex = nindexes > 0;
475 if (indexpr_item == NULL)
476 elog(
ERROR,
"too few entries in indexprs list");
498 for (
i = 0;
i < attr_cnt;
i++)
500 if (targrows < vacattrstats[
i]->minrows)
501 targrows = vacattrstats[
i]->
minrows;
509 if (targrows < thisdata->vacattrstats[
i]->minrows)
521 if (targrows < minrows)
534 &totalrows, &totaldeadrows);
536 numrows = (*acquirefunc) (onerel, elevel,
538 &totalrows, &totaldeadrows);
559 for (
i = 0;
i < attr_cnt;
i++)
581 if (n_distinct != 0.0)
603 attr_cnt, vacattrstats);
615 attr_cnt, vacattrstats);
653 double totalindexrows;
655 totalindexrows = ceil(thisdata->
tupleFract * totalrows);
667 else if (onerel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
692 else if (onerel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
736 double read_rate = 0;
737 double write_rate = 0;
773 read_rate = (double) BLCKSZ * AnalyzePageMiss / (1024 * 1024) /
774 (delay_in_ms / 1000.0);
775 write_rate = (double) BLCKSZ * AnalyzePageDirty / (1024 * 1024) /
776 (delay_in_ms / 1000.0);
798 read_rate, write_rate);
800 (
long long) AnalyzePageHit,
801 (
long long) AnalyzePageMiss,
802 (
long long) AnalyzePageDirty);
859 double totalindexrows;
884 exprnulls = (
bool *)
palloc(numrows * attr_cnt *
sizeof(
bool));
887 for (rowno = 0; rowno < numrows; rowno++)
903 if (predicate != NULL)
926 for (
i = 0;
i < attr_cnt;
i++)
933 exprvals[tcnt] = (
Datum) 0;
934 exprnulls[tcnt] =
true;
941 exprnulls[tcnt] =
false;
952 thisdata->
tupleFract = (double) numindexrows / (
double) numrows;
953 totalindexrows = ceil(thisdata->
tupleFract * totalrows);
958 if (numindexrows > 0)
961 for (
i = 0;
i < attr_cnt;
i++)
1008 if (attr->attisdropped)
1012 if (attr->attstattarget == 0)
1132 double *totalrows,
double *totaldeadrows)
1135 double samplerows = 0;
1136 double liverows = 0;
1137 double deadrows = 0;
1138 double rowstoskip = -1;
1149 int prefetch_maximum = 0;
1167 if (prefetch_maximum)
1190 if (prefetch_maximum)
1192 for (
int i = 0;
i < prefetch_maximum;
i++)
1208 bool block_accepted;
1243 if (!block_accepted)
1260 if (numrows < targrows)
1272 if (rowstoskip <= 0)
1280 Assert(k >= 0 && k < targrows);
1306 if (numrows == targrows)
1319 *totalrows = floor((liverows / bs.
m) * totalblocks + 0.5);
1320 *totaldeadrows = floor((deadrows / bs.
m) * totalblocks + 0.5);
1325 *totaldeadrows = 0.0;
1332 (
errmsg(
"\"%s\": scanned %d of %u pages, "
1333 "containing %.0f live rows and %.0f dead rows; "
1334 "%d rows in sample, %.0f estimated total rows",
1338 numrows, *totalrows)));
1379 double *totalrows,
double *totaldeadrows)
1412 (
errmsg(
"skipping analyze of \"%s.%s\" inheritance tree --- this inheritance tree contains no child tables",
1429 foreach(lc, tableOIDs)
1443 Assert(childrel != onerel);
1449 if (childrel->
rd_rel->relkind == RELKIND_RELATION ||
1450 childrel->
rd_rel->relkind == RELKIND_MATVIEW)
1456 else if (childrel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
1475 Assert(childrel != onerel);
1486 Assert(childrel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
1487 if (childrel != onerel)
1496 rels[nrels] = childrel;
1497 acquirefuncs[nrels] = acquirefunc;
1498 relblocks[nrels] = (double) relpages;
1499 totalblocks += (double) relpages;
1510 (
errmsg(
"skipping analyze of \"%s.%s\" inheritance tree --- this inheritance tree contains no analyzable child tables",
1527 for (
i = 0;
i < nrels;
i++)
1531 double childblocks = relblocks[
i];
1536 if (childblocks > 0)
1540 childtargrows = (int) rint(targrows * childblocks / totalblocks);
1542 childtargrows =
Min(childtargrows, targrows - numrows);
1543 if (childtargrows > 0)
1550 childrows = (*acquirefunc) (childrel, elevel,
1551 rows + numrows, childtargrows,
1555 if (childrows > 0 &&
1567 for (
j = 0;
j < childrows;
j++)
1573 rows[numrows +
j] = newtup;
1580 numrows += childrows;
1581 *totalrows += trows;
1582 *totaldeadrows += tdrows;
1633 for (attno = 0; attno < natts; attno++)
1642 bool nulls[Natts_pg_statistic];
1643 bool replaces[Natts_pg_statistic];
1652 for (
i = 0;
i < Natts_pg_statistic; ++
i)
1664 i = Anum_pg_statistic_stakind1 - 1;
1669 i = Anum_pg_statistic_staop1 - 1;
1674 i = Anum_pg_statistic_stacoll1 - 1;
1679 i = Anum_pg_statistic_stanumbers1 - 1;
1689 for (n = 0; n < nnum; n++)
1700 i = Anum_pg_statistic_stavalues1 - 1;
1729 if (indstate == NULL)
1753 if (indstate != NULL)
1811 #define WIDTH_THRESHOLD 1024
1813 #define swapInt(a,b) do {int _tmp; _tmp=a; a=b; b=_tmp;} while(0)
1814 #define swapDatum(a,b) do {Datum _tmp; _tmp=a; a=b; b=_tmp;} while(0)
1867 if (attr->attstattarget < 0)
1872 false,
false,
false,
1873 <opr, &eqopr, NULL,
1878 mystats->
eqopr = eqopr;
1880 mystats->
ltopr = ltopr;
1909 stats->
minrows = 300 * attr->attstattarget;
1916 stats->
minrows = 300 * attr->attstattarget;
1923 stats->
minrows = 300 * attr->attstattarget;
1945 int nonnull_cnt = 0;
1946 double total_width = 0;
1947 bool is_varlena = (!stats->
attrtype->typbyval &&
1949 bool is_varwidth = (!stats->
attrtype->typbyval &&
1952 for (
i = 0;
i < samplerows;
i++)
1959 value = fetchfunc(stats,
i, &isnull);
1979 else if (is_varwidth)
1987 if (nonnull_cnt > 0)
1991 stats->
stanullfrac = (double) null_cnt / (
double) samplerows;
1993 stats->
stawidth = total_width / (double) nonnull_cnt;
1998 else if (null_cnt > 0)
2035 int nonnull_cnt = 0;
2036 int toowide_cnt = 0;
2037 double total_width = 0;
2038 bool is_varlena = (!stats->
attrtype->typbyval &&
2040 bool is_varwidth = (!stats->
attrtype->typbyval &&
2051 int num_mcv = stats->
attr->attstattarget;
2057 track_max = 2 * num_mcv;
2065 for (
i = 0;
i < samplerows;
i++)
2075 value = fetchfunc(stats,
i, &isnull);
2109 else if (is_varwidth)
2119 firstcount1 = track_cnt;
2120 for (
j = 0;
j < track_cnt;
j++)
2129 if (
j < firstcount1 && track[
j].count == 1)
2138 while (
j > 0 && track[
j].count > track[
j - 1].count)
2141 swapInt(track[
j].count, track[
j - 1].count);
2148 if (track_cnt < track_max)
2150 for (
j = track_cnt - 1;
j > firstcount1;
j--)
2152 track[
j].value = track[
j - 1].value;
2153 track[
j].count = track[
j - 1].count;
2155 if (firstcount1 < track_cnt)
2157 track[firstcount1].value =
value;
2158 track[firstcount1].count = 1;
2164 if (nonnull_cnt > 0)
2171 stats->
stanullfrac = (double) null_cnt / (
double) samplerows;
2173 stats->
stawidth = total_width / (double) nonnull_cnt;
2179 for (nmultiple = 0; nmultiple < track_cnt; nmultiple++)
2181 if (track[nmultiple].count == 1)
2183 summultiple += track[nmultiple].count;
2194 else if (track_cnt < track_max && toowide_cnt == 0 &&
2195 nmultiple == track_cnt)
2234 int f1 = nonnull_cnt - summultiple;
2235 int d =
f1 + nmultiple;
2236 double n = samplerows - null_cnt;
2237 double N = totalrows * (1.0 - stats->
stanullfrac);
2242 stadistinct = (n * d) / ((n -
f1) +
f1 * n / N);
2247 if (stadistinct < d)
2249 if (stadistinct > N)
2280 if (track_cnt < track_max && toowide_cnt == 0 &&
2282 track_cnt <= num_mcv)
2285 num_mcv = track_cnt;
2292 if (num_mcv > track_cnt)
2293 num_mcv = track_cnt;
2297 mcv_counts = (
int *)
palloc(num_mcv *
sizeof(
int));
2298 for (
i = 0;
i < num_mcv;
i++)
2299 mcv_counts[
i] = track[
i].count;
2304 samplerows, totalrows);
2319 for (
i = 0;
i < num_mcv;
i++)
2324 mcv_freqs[
i] = (double) track[
i].count / (
double) samplerows;
2328 stats->
stakind[0] = STATISTIC_KIND_MCV;
2342 else if (null_cnt > 0)
2378 int nonnull_cnt = 0;
2379 int toowide_cnt = 0;
2380 double total_width = 0;
2381 bool is_varlena = (!stats->
attrtype->typbyval &&
2383 bool is_varwidth = (!stats->
attrtype->typbyval &&
2392 int num_mcv = stats->
attr->attstattarget;
2393 int num_bins = stats->
attr->attstattarget;
2397 tupnoLink = (
int *)
palloc(samplerows *
sizeof(
int));
2400 memset(&ssup, 0,
sizeof(ssup));
2415 for (
i = 0;
i < samplerows;
i++)
2422 value = fetchfunc(stats,
i, &isnull);
2456 else if (is_varwidth)
2464 values[values_cnt].tupno = values_cnt;
2465 tupnoLink[values_cnt] = values_cnt;
2508 for (
i = 0;
i < values_cnt;
i++)
2512 corr_xysum += ((double)
i) * ((double) tupno);
2514 if (tupnoLink[tupno] == tupno)
2521 if (track_cnt < num_mcv ||
2522 dups_cnt > track[track_cnt - 1].count)
2532 if (track_cnt < num_mcv)
2534 for (
j = track_cnt - 1;
j > 0;
j--)
2536 if (dups_cnt <= track[
j - 1].count)
2541 track[
j].
count = dups_cnt;
2542 track[
j].
first =
i + 1 - dups_cnt;
2551 stats->
stanullfrac = (double) null_cnt / (
double) samplerows;
2553 stats->
stawidth = total_width / (double) nonnull_cnt;
2565 else if (toowide_cnt == 0 && nmultiple == ndistinct)
2599 int f1 = ndistinct - nmultiple + toowide_cnt;
2600 int d =
f1 + nmultiple;
2601 double n = samplerows - null_cnt;
2602 double N = totalrows * (1.0 - stats->
stanullfrac);
2607 stadistinct = (n * d) / ((n -
f1) +
f1 * n / N);
2612 if (stadistinct < d)
2614 if (stadistinct > N)
2645 if (track_cnt == ndistinct && toowide_cnt == 0 &&
2647 track_cnt <= num_mcv)
2650 num_mcv = track_cnt;
2657 if (num_mcv > track_cnt)
2658 num_mcv = track_cnt;
2662 mcv_counts = (
int *)
palloc(num_mcv *
sizeof(
int));
2663 for (
i = 0;
i < num_mcv;
i++)
2664 mcv_counts[
i] = track[
i].count;
2669 samplerows, totalrows);
2684 for (
i = 0;
i < num_mcv;
i++)
2689 mcv_freqs[
i] = (double) track[
i].count / (
double) samplerows;
2693 stats->
stakind[slot_idx] = STATISTIC_KIND_MCV;
2698 stats->
stavalues[slot_idx] = mcv_values;
2713 num_hist = ndistinct - num_mcv;
2714 if (num_hist > num_bins)
2715 num_hist = num_bins + 1;
2745 while (src < values_cnt)
2751 int first = track[
j].
first;
2756 src = first + track[
j].
count;
2760 ncopy = first - src;
2763 ncopy = values_cnt - src;
2773 Assert(nvals >= num_hist);
2788 delta = (nvals - 1) / (num_hist - 1);
2789 deltafrac = (nvals - 1) % (num_hist - 1);
2792 for (
i = 0;
i < num_hist;
i++)
2798 posfrac += deltafrac;
2799 if (posfrac >= (num_hist - 1))
2803 posfrac -= (num_hist - 1);
2809 stats->
stakind[slot_idx] = STATISTIC_KIND_HISTOGRAM;
2812 stats->
stavalues[slot_idx] = hist_values;
2844 corr_xsum = ((double) (values_cnt - 1)) *
2845 ((
double) values_cnt) / 2.0;
2846 corr_x2sum = ((double) (values_cnt - 1)) *
2847 ((
double) values_cnt) * (
double) (2 * values_cnt - 1) / 6.0;
2850 corrs[0] = (values_cnt * corr_xysum - corr_xsum * corr_xsum) /
2851 (values_cnt * corr_x2sum - corr_xsum * corr_xsum);
2853 stats->
stakind[slot_idx] = STATISTIC_KIND_CORRELATION;
2861 else if (nonnull_cnt > 0)
2864 Assert(nonnull_cnt == toowide_cnt);
2867 stats->
stanullfrac = (double) null_cnt / (
double) samplerows;
2869 stats->
stawidth = total_width / (double) nonnull_cnt;
2875 else if (null_cnt > 0)
2956 double ndistinct_table;
2964 if (samplerows == totalrows || totalrows <= 1.0)
2968 ndistinct_table = stadistinct;
2969 if (ndistinct_table < 0)
2970 ndistinct_table = -ndistinct_table * totalrows;
2992 for (
i = 0;
i < num_mcv - 1;
i++)
2993 sumcount += mcv_counts[
i];
3009 selec = 1.0 - sumcount / samplerows - stanullfrac;
3014 otherdistinct = ndistinct_table - (num_mcv - 1);
3015 if (otherdistinct > 1)
3016 selec /= otherdistinct;
3036 K = N * mcv_counts[num_mcv - 1] / n;
3037 variance = n *
K * (N -
K) * (N - n) / (N * N * (N - 1));
3038 stddev = sqrt(variance);
3040 if (mcv_counts[num_mcv - 1] > selec * samplerows + 2 * stddev + 0.5)
3055 sumcount -= mcv_counts[num_mcv - 1];
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
ArrayType * construct_array(Datum *elems, int nelems, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
#define InvalidAttrNumber
AttributeOpts * get_attribute_options(Oid attrelid, int attnum)
bool IsAutoVacuumWorkerProcess(void)
long TimestampDifferenceMilliseconds(TimestampTz start_time, TimestampTz stop_time)
bool TimestampDifferenceExceeds(TimestampTz start_time, TimestampTz stop_time, int msec)
TimestampTz GetCurrentTimestamp(void)
void pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
void pgstat_progress_update_param(int index, int64 val)
void pgstat_progress_end_command(void)
@ PROGRESS_COMMAND_ANALYZE
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
#define InvalidBlockNumber
static Datum values[MAXATTR]
PrefetchBufferResult PrefetchBuffer(Relation reln, ForkNumber forkNum, BlockNumber blockNum)
#define RelationGetNumberOfBlocks(reln)
#define OidIsValid(objectId)
static Datum std_fetch_func(VacAttrStatsP stats, int rownum, bool *isNull)
static void compute_scalar_stats(VacAttrStatsP stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows)
static void update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
int default_statistics_target
static void compute_distinct_stats(VacAttrStatsP stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows)
static MemoryContext anl_context
bool std_typanalyze(VacAttrStats *stats)
static int analyze_mcv_list(int *mcv_counts, int num_mcv, double stadistinct, double stanullfrac, int samplerows, double totalrows)
static int acquire_inherited_sample_rows(Relation onerel, int elevel, HeapTuple *rows, int targrows, double *totalrows, double *totaldeadrows)
static BufferAccessStrategy vac_strategy
static int compare_mcvs(const void *a, const void *b, void *arg)
struct AnlIndexData AnlIndexData
static int acquire_sample_rows(Relation onerel, int elevel, HeapTuple *rows, int targrows, double *totalrows, double *totaldeadrows)
static void compute_trivial_stats(VacAttrStatsP stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows)
static int compare_scalars(const void *a, const void *b, void *arg)
static Datum ind_fetch_func(VacAttrStatsP stats, int rownum, bool *isNull)
void analyze_rel(Oid relid, RangeVar *relation, VacuumParams *params, List *va_cols, bool in_outer_xact, BufferAccessStrategy bstrategy)
static void do_analyze_rel(Relation onerel, VacuumParams *params, List *va_cols, AcquireSampleRowsFunc acquirefunc, BlockNumber relpages, bool inh, bool in_outer_xact, int elevel)
static VacAttrStats * examine_attribute(Relation onerel, int attnum, Node *index_expr)
static int compare_rows(const void *a, const void *b, void *arg)
static void compute_index_stats(Relation onerel, double totalrows, AnlIndexData *indexdata, int nindexes, HeapTuple *rows, int numrows, MemoryContext col_context)
Datum datumCopy(Datum value, bool typByVal, int typLen)
char * get_database_name(Oid dbid)
elog(ERROR, "%s: %s", p2, msg)
Size toast_raw_datum_size(Datum value)
int errmsg_internal(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
ExprState * ExecPrepareQual(List *qual, EState *estate)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
TupleTableSlot * ExecStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
const TupleTableSlotOps TTSOpsHeapTuple
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
EState * CreateExecutorState(void)
void FreeExecutorState(EState *estate)
#define GetPerTupleExprContext(estate)
#define ResetExprContext(econtext)
static bool ExecQual(ExprState *state, ExprContext *econtext)
int ComputeExtStatisticsRows(Relation onerel, int natts, VacAttrStats **vacattrstats)
void BuildRelationExtStatistics(Relation onerel, bool inh, double totalrows, int numrows, HeapTuple *rows, int natts, VacAttrStats **vacattrstats)
int(* AcquireSampleRowsFunc)(Relation relation, int elevel, HeapTuple *rows, int targrows, double *totalrows, double *totaldeadrows)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
#define OidFunctionCall1(functionId, arg1)
#define PG_DETOAST_DATUM(datum)
FdwRoutine * GetFdwRoutineForRelation(Relation relation, bool makecopy)
static int compare(const void *arg1, const void *arg2)
int NewGUCNestLevel(void)
void AtEOXact_GUC(bool isCommit, int nestLevel)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, bool *replIsnull, bool *doReplace)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
void FormIndexDatum(IndexInfo *indexInfo, TupleTableSlot *slot, EState *estate, Datum *values, bool *isnull)
IndexInfo * BuildIndexInfo(Relation index)
IndexBulkDeleteResult * index_vacuum_cleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *istat)
void CatalogTupleInsertWithInfo(Relation heapRel, HeapTuple tup, CatalogIndexState indstate)
void CatalogCloseIndexes(CatalogIndexState indstate)
CatalogIndexState CatalogOpenIndexes(Relation heapRel)
void CatalogTupleUpdateWithInfo(Relation heapRel, ItemPointer otid, HeapTuple tup, CatalogIndexState indstate)
if(TABLE==NULL||TABLE_index==NULL)
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
Assert(fmt[strlen(fmt) - 1] !='\n')
void list_free(List *list)
#define ShareUpdateExclusiveLock
char * get_namespace_name(Oid nspid)
RegProcedure get_opcode(Oid opno)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define MemoryContextResetAndDeleteChildren(ctx)
#define SECURITY_RESTRICTED_OPERATION
#define CHECK_FOR_INTERRUPTS()
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
void SetUserIdAndSecContext(Oid userid, int sec_context)
#define InvalidMultiXactId
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
void get_sort_group_operators(Oid argtype, bool needLT, bool needEQ, bool needGT, Oid *ltOpr, Oid *eqOpr, Oid *gtOpr, bool *isHashable)
int attnameAttNum(Relation rd, const char *attname, bool sysColOK)
#define ATTRIBUTE_FIXED_PART_SIZE
FormData_pg_attribute * Form_pg_attribute
List * find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents)
static int list_length(const List *l)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
uint32 pg_prng_uint32(pg_prng_state *state)
pg_prng_state pg_global_prng_state
const char * pg_rusage_show(const PGRUsage *ru0)
void pg_rusage_init(PGRUsage *ru0)
#define STATISTIC_NUM_SLOTS
FormData_pg_type * Form_pg_type
PgStat_Counter pgStatBlockReadTime
PgStat_Counter pgStatBlockWriteTime
void pgstat_report_analyze(Relation rel, PgStat_Counter livetuples, PgStat_Counter deadtuples, bool resetcounter)
void qsort_interruptible(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum Float4GetDatum(float4 X)
static char * DatumGetCString(Datum X)
static Datum Int16GetDatum(int16 X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static Datum Int32GetDatum(int32 X)
TransactionId GetOldestNonRemovableTransactionId(Relation rel)
#define PROGRESS_ANALYZE_PHASE_FINALIZE_ANALYZE
#define PROGRESS_ANALYZE_PHASE_ACQUIRE_SAMPLE_ROWS_INH
#define PROGRESS_ANALYZE_BLOCKS_DONE
#define PROGRESS_ANALYZE_PHASE
#define PROGRESS_ANALYZE_CHILD_TABLES_TOTAL
#define PROGRESS_ANALYZE_BLOCKS_TOTAL
#define PROGRESS_ANALYZE_PHASE_COMPUTE_STATS
#define PROGRESS_ANALYZE_PHASE_ACQUIRE_SAMPLE_ROWS
#define PROGRESS_ANALYZE_CHILD_TABLES_DONE
#define PROGRESS_ANALYZE_CURRENT_CHILD_TABLE_RELID
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define RELATION_IS_OTHER_TEMP(relation)
#define RelationGetNamespace(relation)
List * RelationGetIndexList(Relation relation)
struct RelationData * Relation
BlockNumber BlockSampler_Init(BlockSampler bs, BlockNumber nblocks, int samplesize, uint32 randseed)
void reservoir_init_selection_state(ReservoirState rs, int n)
double sampler_random_fract(pg_prng_state *randstate)
bool BlockSampler_HasMore(BlockSampler bs)
BlockNumber BlockSampler_Next(BlockSampler bs)
double reservoir_get_next_S(ReservoirState rs, double t, int n)
void PrepareSortSupportFromOrderingOp(Oid orderingOp, SortSupport ssup)
static int ApplySortComparator(Datum datum1, bool isNull1, Datum datum2, bool isNull2, SortSupport ssup)
int get_tablespace_maintenance_io_concurrency(Oid spcid)
void relation_close(Relation relation, LOCKMODE lockmode)
void appendStringInfo(StringInfo str, const char *fmt,...)
void initStringInfo(StringInfo str)
VacAttrStats ** vacattrstats
float8 n_distinct_inherited
TupleTableSlot * ecxt_scantuple
AnalyzeForeignTable_function AnalyzeForeignTable
AttrNumber ii_IndexAttrNumbers[INDEX_MAX_KEYS]
BufferAccessStrategy strategy
int16 stakind[STATISTIC_NUM_SLOTS]
MemoryContext anl_context
Oid statypid[STATISTIC_NUM_SLOTS]
Oid staop[STATISTIC_NUM_SLOTS]
Oid stacoll[STATISTIC_NUM_SLOTS]
char statypalign[STATISTIC_NUM_SLOTS]
float4 * stanumbers[STATISTIC_NUM_SLOTS]
bool statypbyval[STATISTIC_NUM_SLOTS]
int16 statyplen[STATISTIC_NUM_SLOTS]
int numvalues[STATISTIC_NUM_SLOTS]
Datum * stavalues[STATISTIC_NUM_SLOTS]
int numnumbers[STATISTIC_NUM_SLOTS]
AnalyzeAttrComputeStatsFunc compute_stats
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
#define SearchSysCacheCopy1(cacheId, key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
static bool table_scan_analyze_next_block(TableScanDesc scan, BlockNumber blockno, BufferAccessStrategy bstrategy)
static void table_endscan(TableScanDesc scan)
static bool table_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin, double *liverows, double *deadrows, TupleTableSlot *slot)
static TableScanDesc table_beginscan_analyze(Relation rel)
void SetRelationHasSubclass(Oid relationId, bool relhassubclass)
#define InvalidTransactionId
void free_conversion_map(TupleConversionMap *map)
TupleConversionMap * convert_tuples_by_name(TupleDesc indesc, TupleDesc outdesc)
HeapTuple execute_attr_map_tuple(HeapTuple tuple, TupleConversionMap *map)
bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
#define TupleDescAttr(tupdesc, i)
static HeapTuple ExecCopySlotHeapTuple(TupleTableSlot *slot)
void vac_open_indexes(Relation relation, LOCKMODE lockmode, int *nindexes, Relation **Irel)
void vac_update_relstats(Relation relation, BlockNumber num_pages, double num_tuples, BlockNumber num_all_visible_pages, bool hasindex, TransactionId frozenxid, MultiXactId minmulti, bool *frozenxid_updated, bool *minmulti_updated, bool in_outer_xact)
Relation vacuum_open_relation(Oid relid, RangeVar *relation, bits32 options, bool verbose, LOCKMODE lmode)
void vac_close_indexes(int nindexes, Relation *Irel, LOCKMODE lockmode)
void vacuum_delay_point(void)
bool vacuum_is_permitted_for_relation(Oid relid, Form_pg_class reltuple, bits32 options)
Datum(* AnalyzeAttrFetchFunc)(VacAttrStatsP stats, int rownum, bool *isNull)
void visibilitymap_count(Relation rel, BlockNumber *all_visible, BlockNumber *all_frozen)
void CommandCounterIncrement(void)