80 bool inh,
bool in_outer_xact,
int elevel);
89 double *totalrows,
double *totaldeadrows);
93 double *totalrows,
double *totaldeadrows);
187 if (onerel->
rd_rel->relkind == RELKIND_RELATION ||
188 onerel->
rd_rel->relkind == RELKIND_MATVIEW)
195 else if (onerel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
214 (
errmsg(
"skipping \"%s\" --- cannot analyze this foreign table",
220 else if (onerel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
231 (
errmsg(
"skipping \"%s\" --- cannot analyze non-tables or special system tables",
253 if (onerel->
rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
255 relpages,
false, in_outer_xact, elevel);
260 if (onerel->
rd_rel->relhassubclass)
262 true, in_outer_xact, elevel);
285 BlockNumber relpages,
bool inh,
bool in_outer_xact,
309 int save_sec_context;
322 (
errmsg(
"analyzing \"%s.%s\" inheritance tree",
327 (
errmsg(
"analyzing \"%s.%s\"",
392 (
errcode(ERRCODE_UNDEFINED_COLUMN),
393 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
397 (
errcode(ERRCODE_DUPLICATE_COLUMN),
398 errmsg(
"column \"%s\" of relation \"%s\" appears more than once",
403 if (vacattrstats[tcnt] != NULL)
414 for (
i = 1;
i <= attr_cnt;
i++)
417 if (vacattrstats[tcnt] != NULL)
432 if (onerel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
438 hasindex = idxs !=
NIL;
444 hasindex = nindexes > 0;
479 if (indexpr_item == NULL)
480 elog(
ERROR,
"too few entries in indexprs list");
502 for (
i = 0;
i < attr_cnt;
i++)
504 if (targrows < vacattrstats[
i]->minrows)
505 targrows = vacattrstats[
i]->
minrows;
513 if (targrows < thisdata->vacattrstats[
i]->minrows)
525 if (targrows < minrows)
538 &totalrows, &totaldeadrows);
540 numrows = (*acquirefunc) (onerel, elevel,
542 &totalrows, &totaldeadrows);
563 for (
i = 0;
i < attr_cnt;
i++)
585 if (n_distinct != 0.0)
607 attr_cnt, vacattrstats);
619 attr_cnt, vacattrstats);
641 if (RELKIND_HAS_STORAGE(onerel->
rd_rel->relkind))
664 double totalindexrows;
666 totalindexrows = ceil(thisdata->
tupleFract * totalrows);
678 else if (onerel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
703 (va_cols ==
NIL), starttime);
704 else if (onerel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
750 double read_rate = 0;
751 double write_rate = 0;
754 int64 total_blks_hit;
755 int64 total_blks_read;
756 int64 total_blks_dirtied;
760 memset(&walusage, 0,
sizeof(
WalUsage));
794 read_rate = (double) BLCKSZ * total_blks_read /
795 (1024 * 1024) / (delay_in_ms / 1000.0);
796 write_rate = (double) BLCKSZ * total_blks_dirtied /
797 (1024 * 1024) / (delay_in_ms / 1000.0);
808 msgfmt =
_(
"automatic analyze of table \"%s.%s.%s\"\n");
810 msgfmt =
_(
"finished analyzing table \"%s.%s.%s\"\n");
834 read_rate, write_rate);
835 appendStringInfo(&
buf,
_(
"buffer usage: %" PRId64
" hits, %" PRId64
" reads, %" PRId64
" dirtied\n"),
840 _(
"WAL usage: %" PRId64
" records, %" PRId64
" full page images, %" PRIu64
" bytes, %" PRIu64
" full page image bytes, %" PRId64
" buffers full\n"),
902 double totalindexrows;
927 exprnulls = (
bool *)
palloc(numrows * attr_cnt *
sizeof(
bool));
930 for (rowno = 0; rowno < numrows; rowno++)
946 if (predicate != NULL)
969 for (
i = 0;
i < attr_cnt;
i++)
976 exprvals[tcnt] = (
Datum) 0;
977 exprnulls[tcnt] =
true;
984 exprnulls[tcnt] =
false;
995 thisdata->
tupleFract = (double) numindexrows / (
double) numrows;
996 totalindexrows = ceil(thisdata->
tupleFract * totalrows);
1001 if (numindexrows > 0)
1004 for (
i = 0;
i < attr_cnt;
i++)
1055 if (attr->attisdropped)
1059 if (attr->attgenerated == ATTRIBUTE_GENERATED_VIRTUAL)
1069 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
1071 dat =
SysCacheGetAttr(ATTNUM, atttuple, Anum_pg_attribute_attstattarget, &isnull);
1076 if (attstattarget == 0)
1163 void *callback_private_data,
1164 void *per_buffer_data)
1207 double *totalrows,
double *totaldeadrows)
1210 double samplerows = 0;
1211 double liverows = 0;
1212 double deadrows = 0;
1213 double rowstoskip = -1;
1278 if (numrows < targrows)
1290 if (rowstoskip <= 0)
1298 Assert(k >= 0 && k < targrows);
1326 if (numrows == targrows)
1339 *totalrows = floor((liverows / bs.
m) * totalblocks + 0.5);
1340 *totaldeadrows = floor((deadrows / bs.
m) * totalblocks + 0.5);
1345 *totaldeadrows = 0.0;
1352 (
errmsg(
"\"%s\": scanned %d of %u pages, "
1353 "containing %.0f live rows and %.0f dead rows; "
1354 "%d rows in sample, %.0f estimated total rows",
1358 numrows, *totalrows)));
1399 double *totalrows,
double *totaldeadrows)
1436 (
errmsg(
"skipping analyze of \"%s.%s\" inheritance tree --- this inheritance tree contains no child tables",
1453 foreach(lc, tableOIDs)
1467 Assert(childrel != onerel);
1473 if (childrel->
rd_rel->relkind == RELKIND_RELATION ||
1474 childrel->
rd_rel->relkind == RELKIND_MATVIEW)
1480 else if (childrel->
rd_rel->relkind == RELKIND_FOREIGN_TABLE)
1499 Assert(childrel != onerel);
1510 Assert(childrel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
1511 if (childrel != onerel)
1520 rels[nrels] = childrel;
1521 acquirefuncs[nrels] = acquirefunc;
1522 relblocks[nrels] = (double) relpages;
1523 totalblocks += (double) relpages;
1534 (
errmsg(
"skipping analyze of \"%s.%s\" inheritance tree --- this inheritance tree contains no analyzable child tables",
1549 for (
i = 0;
i < nrels;
i++)
1553 double childblocks = relblocks[
i];
1561 const int progress_index[] = {
1566 const int64 progress_vals[] = {
1575 if (childblocks > 0)
1579 childtargrows = (int) rint(targrows * childblocks / totalblocks);
1581 childtargrows =
Min(childtargrows, targrows - numrows);
1582 if (childtargrows > 0)
1589 childrows = (*acquirefunc) (childrel, elevel,
1590 rows + numrows, childtargrows,
1594 if (childrows > 0 &&
1606 for (
j = 0;
j < childrows;
j++)
1612 rows[numrows +
j] = newtup;
1619 numrows += childrows;
1620 *totalrows += trows;
1621 *totaldeadrows += tdrows;
1672 for (attno = 0; attno < natts; attno++)
1681 bool nulls[Natts_pg_statistic];
1682 bool replaces[Natts_pg_statistic];
1691 for (
i = 0;
i < Natts_pg_statistic; ++
i)
1703 i = Anum_pg_statistic_stakind1 - 1;
1708 i = Anum_pg_statistic_staop1 - 1;
1713 i = Anum_pg_statistic_stacoll1 - 1;
1718 i = Anum_pg_statistic_stanumbers1 - 1;
1727 for (n = 0; n < nnum; n++)
1738 i = Anum_pg_statistic_stavalues1 - 1;
1767 if (indstate == NULL)
1791 if (indstate != NULL)
1849#define WIDTH_THRESHOLD 1024
1851#define swapInt(a,b) do {int _tmp; _tmp=a; a=b; b=_tmp;} while(0)
1852#define swapDatum(a,b) do {Datum _tmp; _tmp=a; a=b; b=_tmp;} while(0)
1908 false,
false,
false,
1909 <opr, &eqopr, NULL,
1914 mystats->
eqopr = eqopr;
1916 mystats->
ltopr = ltopr;
1981 int nonnull_cnt = 0;
1982 double total_width = 0;
1983 bool is_varlena = (!stats->
attrtype->typbyval &&
1985 bool is_varwidth = (!stats->
attrtype->typbyval &&
1988 for (
i = 0;
i < samplerows;
i++)
1995 value = fetchfunc(stats,
i, &isnull);
2015 else if (is_varwidth)
2023 if (nonnull_cnt > 0)
2027 stats->
stanullfrac = (double) null_cnt / (
double) samplerows;
2029 stats->
stawidth = total_width / (double) nonnull_cnt;
2034 else if (null_cnt > 0)
2071 int nonnull_cnt = 0;
2072 int toowide_cnt = 0;
2073 double total_width = 0;
2074 bool is_varlena = (!stats->
attrtype->typbyval &&
2076 bool is_varwidth = (!stats->
attrtype->typbyval &&
2093 track_max = 2 * num_mcv;
2101 for (
i = 0;
i < samplerows;
i++)
2111 value = fetchfunc(stats,
i, &isnull);
2145 else if (is_varwidth)
2155 firstcount1 = track_cnt;
2156 for (
j = 0;
j < track_cnt;
j++)
2165 if (
j < firstcount1 && track[
j].count == 1)
2174 while (
j > 0 && track[
j].count > track[
j - 1].count)
2177 swapInt(track[
j].count, track[
j - 1].count);
2184 if (track_cnt < track_max)
2186 for (
j = track_cnt - 1;
j > firstcount1;
j--)
2188 track[
j].value = track[
j - 1].value;
2189 track[
j].count = track[
j - 1].count;
2191 if (firstcount1 < track_cnt)
2193 track[firstcount1].value =
value;
2194 track[firstcount1].count = 1;
2200 if (nonnull_cnt > 0)
2207 stats->
stanullfrac = (double) null_cnt / (
double) samplerows;
2209 stats->
stawidth = total_width / (double) nonnull_cnt;
2215 for (nmultiple = 0; nmultiple < track_cnt; nmultiple++)
2217 if (track[nmultiple].count == 1)
2219 summultiple += track[nmultiple].count;
2230 else if (track_cnt < track_max && toowide_cnt == 0 &&
2231 nmultiple == track_cnt)
2270 int f1 = nonnull_cnt - summultiple;
2271 int d =
f1 + nmultiple;
2272 double n = samplerows - null_cnt;
2273 double N = totalrows * (1.0 - stats->
stanullfrac);
2278 stadistinct = (n * d) / ((n -
f1) +
f1 * n / N);
2283 if (stadistinct < d)
2285 if (stadistinct > N)
2316 if (track_cnt < track_max && toowide_cnt == 0 &&
2318 track_cnt <= num_mcv)
2321 num_mcv = track_cnt;
2328 if (num_mcv > track_cnt)
2329 num_mcv = track_cnt;
2333 mcv_counts = (
int *)
palloc(num_mcv *
sizeof(
int));
2334 for (
i = 0;
i < num_mcv;
i++)
2335 mcv_counts[
i] = track[
i].count;
2340 samplerows, totalrows);
2355 for (
i = 0;
i < num_mcv;
i++)
2360 mcv_freqs[
i] = (double) track[
i].count / (
double) samplerows;
2364 stats->
stakind[0] = STATISTIC_KIND_MCV;
2378 else if (null_cnt > 0)
2414 int nonnull_cnt = 0;
2415 int toowide_cnt = 0;
2416 double total_width = 0;
2417 bool is_varlena = (!stats->
attrtype->typbyval &&
2419 bool is_varwidth = (!stats->
attrtype->typbyval &&
2433 tupnoLink = (
int *)
palloc(samplerows *
sizeof(
int));
2436 memset(&ssup, 0,
sizeof(ssup));
2451 for (
i = 0;
i < samplerows;
i++)
2458 value = fetchfunc(stats,
i, &isnull);
2492 else if (is_varwidth)
2500 values[values_cnt].tupno = values_cnt;
2501 tupnoLink[values_cnt] = values_cnt;
2544 for (
i = 0;
i < values_cnt;
i++)
2548 corr_xysum += ((double)
i) * ((double) tupno);
2550 if (tupnoLink[tupno] == tupno)
2557 if (track_cnt < num_mcv ||
2558 dups_cnt > track[track_cnt - 1].count)
2568 if (track_cnt < num_mcv)
2570 for (
j = track_cnt - 1;
j > 0;
j--)
2572 if (dups_cnt <= track[
j - 1].count)
2577 track[
j].
count = dups_cnt;
2578 track[
j].
first =
i + 1 - dups_cnt;
2587 stats->
stanullfrac = (double) null_cnt / (
double) samplerows;
2589 stats->
stawidth = total_width / (double) nonnull_cnt;
2601 else if (toowide_cnt == 0 && nmultiple == ndistinct)
2635 int f1 = ndistinct - nmultiple + toowide_cnt;
2636 int d =
f1 + nmultiple;
2637 double n = samplerows - null_cnt;
2638 double N = totalrows * (1.0 - stats->
stanullfrac);
2643 stadistinct = (n * d) / ((n -
f1) +
f1 * n / N);
2648 if (stadistinct < d)
2650 if (stadistinct > N)
2681 if (track_cnt == ndistinct && toowide_cnt == 0 &&
2683 track_cnt <= num_mcv)
2686 num_mcv = track_cnt;
2693 if (num_mcv > track_cnt)
2694 num_mcv = track_cnt;
2698 mcv_counts = (
int *)
palloc(num_mcv *
sizeof(
int));
2699 for (
i = 0;
i < num_mcv;
i++)
2700 mcv_counts[
i] = track[
i].count;
2705 samplerows, totalrows);
2720 for (
i = 0;
i < num_mcv;
i++)
2725 mcv_freqs[
i] = (double) track[
i].count / (
double) samplerows;
2729 stats->
stakind[slot_idx] = STATISTIC_KIND_MCV;
2734 stats->
stavalues[slot_idx] = mcv_values;
2749 num_hist = ndistinct - num_mcv;
2750 if (num_hist > num_bins)
2751 num_hist = num_bins + 1;
2781 while (src < values_cnt)
2787 int first = track[
j].
first;
2792 src = first + track[
j].
count;
2796 ncopy = first - src;
2799 ncopy = values_cnt - src;
2809 Assert(nvals >= num_hist);
2824 delta = (nvals - 1) / (num_hist - 1);
2825 deltafrac = (nvals - 1) % (num_hist - 1);
2828 for (
i = 0;
i < num_hist;
i++)
2834 posfrac += deltafrac;
2835 if (posfrac >= (num_hist - 1))
2839 posfrac -= (num_hist - 1);
2845 stats->
stakind[slot_idx] = STATISTIC_KIND_HISTOGRAM;
2848 stats->
stavalues[slot_idx] = hist_values;
2880 corr_xsum = ((double) (values_cnt - 1)) *
2881 ((
double) values_cnt) / 2.0;
2882 corr_x2sum = ((double) (values_cnt - 1)) *
2883 ((
double) values_cnt) * (
double) (2 * values_cnt - 1) / 6.0;
2886 corrs[0] = (values_cnt * corr_xysum - corr_xsum * corr_xsum) /
2887 (values_cnt * corr_x2sum - corr_xsum * corr_xsum);
2889 stats->
stakind[slot_idx] = STATISTIC_KIND_CORRELATION;
2897 else if (nonnull_cnt > 0)
2900 Assert(nonnull_cnt == toowide_cnt);
2903 stats->
stanullfrac = (double) null_cnt / (
double) samplerows;
2905 stats->
stawidth = total_width / (double) nonnull_cnt;
2911 else if (null_cnt > 0)
2992 double ndistinct_table;
3000 if (samplerows == totalrows || totalrows <= 1.0)
3004 ndistinct_table = stadistinct;
3005 if (ndistinct_table < 0)
3006 ndistinct_table = -ndistinct_table * totalrows;
3028 for (
i = 0;
i < num_mcv - 1;
i++)
3029 sumcount += mcv_counts[
i];
3045 selec = 1.0 - sumcount / samplerows - stanullfrac;
3050 otherdistinct = ndistinct_table - (num_mcv - 1);
3051 if (otherdistinct > 1)
3052 selec /= otherdistinct;
3072 K = N * mcv_counts[num_mcv - 1] / n;
3073 variance = n *
K * (N -
K) * (N - n) / (N * N * (N - 1));
3074 stddev = sqrt(variance);
3076 if (mcv_counts[num_mcv - 1] > selec * samplerows + 2 * stddev + 0.5)
3091 sumcount -= mcv_counts[num_mcv - 1];
ArrayType * construct_array(Datum *elems, int nelems, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
#define InvalidAttrNumber
AttributeOpts * get_attribute_options(Oid attrelid, int attnum)
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_update_multi_param(int nparam, const int *index, const int64 *val)
void pgstat_progress_end_command(void)
@ PROGRESS_COMMAND_ANALYZE
PgBackendStatus * MyBEEntry
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
#define InvalidBlockNumber
static Datum values[MAXATTR]
#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 do_analyze_rel(Relation onerel, const VacuumParams params, List *va_cols, AcquireSampleRowsFunc acquirefunc, BlockNumber relpages, bool inh, bool in_outer_xact, int elevel)
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 BlockNumber block_sampling_read_stream_next(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
static int compare_mcvs(const void *a, const void *b, void *arg)
void analyze_rel(Oid relid, RangeVar *relation, const VacuumParams params, List *va_cols, bool in_outer_xact, BufferAccessStrategy bstrategy)
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)
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)
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)
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
const TupleTableSlotOps TTSOpsHeapTuple
TupleTableSlot * ExecStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
void FreeExecutorState(EState *estate)
EState * CreateExecutorState(void)
#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)
#define palloc_object(type)
#define palloc0_object(type)
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)
struct RelationData * Relation
static int compare(const void *arg1, const void *arg2)
int NewGUCNestLevel(void)
void RestrictSearchPath(void)
void AtEOXact_GUC(bool isCommit, int nestLevel)
Assert(PointerIsAligned(start, uint64))
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
static void * GETSTRUCT(const HeapTupleData *tuple)
IndexInfo * BuildIndexInfo(Relation index)
void FormIndexDatum(IndexInfo *indexInfo, TupleTableSlot *slot, EState *estate, Datum *values, bool *isnull)
IndexBulkDeleteResult * index_vacuum_cleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *istat)
void CatalogTupleUpdateWithInfo(Relation heapRel, const ItemPointerData *otid, HeapTuple tup, CatalogIndexState indstate)
void CatalogTupleInsertWithInfo(Relation heapRel, HeapTuple tup, CatalogIndexState indstate)
void CatalogCloseIndexes(CatalogIndexState indstate)
CatalogIndexState CatalogOpenIndexes(Relation heapRel)
void WalUsageAccumDiff(WalUsage *dst, const WalUsage *add, const WalUsage *sub)
BufferUsage pgBufferUsage
void BufferUsageAccumDiff(BufferUsage *dst, const BufferUsage *add, const BufferUsage *sub)
if(TABLE==NULL||TABLE_index==NULL)
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
void list_free(List *list)
#define ShareUpdateExclusiveLock
char * get_database_name(Oid dbid)
RegProcedure get_opcode(Oid opno)
char * get_namespace_name(Oid nspid)
void MemoryContextReset(MemoryContext context)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define AmAutoVacuumWorkerProcess()
#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)
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
static char buf[DEFAULT_XLOG_SEG_SIZE]
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, TimestampTz starttime)
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 Datum Int16GetDatum(int16 X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static char * DatumGetCString(Datum X)
static Pointer DatumGetPointer(Datum X)
static Datum Int32GetDatum(int32 X)
static int16 DatumGetInt16(Datum X)
TransactionId GetOldestNonRemovableTransactionId(Relation rel)
#define PROGRESS_ANALYZE_PHASE_FINALIZE_ANALYZE
#define PROGRESS_ANALYZE_PHASE_ACQUIRE_SAMPLE_ROWS_INH
#define PROGRESS_ANALYZE_STARTED_BY
#define PROGRESS_ANALYZE_BLOCKS_DONE
#define PROGRESS_ANALYZE_PHASE
#define PROGRESS_ANALYZE_CHILD_TABLES_TOTAL
#define PROGRESS_ANALYZE_BLOCKS_TOTAL
#define PROGRESS_ANALYZE_STARTED_BY_AUTOVACUUM
#define PROGRESS_ANALYZE_PHASE_COMPUTE_STATS
#define PROGRESS_ANALYZE_DELAY_TIME
#define PROGRESS_ANALYZE_PHASE_ACQUIRE_SAMPLE_ROWS
#define PROGRESS_ANALYZE_CHILD_TABLES_DONE
#define PROGRESS_ANALYZE_CURRENT_CHILD_TABLE_RELID
#define PROGRESS_ANALYZE_STARTED_BY_MANUAL
ReadStream * read_stream_begin_relation(int flags, BufferAccessStrategy strategy, Relation rel, ForkNumber forknum, ReadStreamBlockNumberCB callback, void *callback_private_data, size_t per_buffer_data_size)
void read_stream_end(ReadStream *stream)
#define READ_STREAM_MAINTENANCE
#define READ_STREAM_USE_BATCHING
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define RELATION_IS_OTHER_TEMP(relation)
#define RelationGetNamespace(relation)
List * RelationGetIndexList(Relation 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)
void relation_close(Relation relation, LOCKMODE lockmode)
void appendStringInfo(StringInfo str, const char *fmt,...)
void initStringInfo(StringInfo str)
VacAttrStats ** vacattrstats
float8 n_distinct_inherited
int64 shared_blks_dirtied
TupleTableSlot * ecxt_scantuple
AnalyzeForeignTable_function AnalyzeForeignTable
AttrNumber ii_IndexAttrNumbers[INDEX_MAX_KEYS]
BufferAccessStrategy strategy
int64 st_progress_param[PGSTAT_NUM_PROGRESS_PARAM]
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
int log_analyze_min_duration
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
#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 void table_endscan(TableScanDesc scan)
static bool table_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin, double *liverows, double *deadrows, TupleTableSlot *slot)
static bool table_scan_analyze_next_block(TableScanDesc scan, ReadStream *stream)
static TableScanDesc table_beginscan_analyze(Relation rel)
void SetRelationHasSubclass(Oid relationId, bool relhassubclass)
#define InvalidTransactionId
TupleConversionMap * convert_tuples_by_name(TupleDesc indesc, TupleDesc outdesc)
void free_conversion_map(TupleConversionMap *map)
HeapTuple execute_attr_map_tuple(HeapTuple tuple, TupleConversionMap *map)
bool equalRowTypes(TupleDesc tupdesc1, TupleDesc tupdesc2)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
static HeapTuple ExecCopySlotHeapTuple(TupleTableSlot *slot)
bool track_cost_delay_timing
void vac_open_indexes(Relation relation, LOCKMODE lockmode, int *nindexes, Relation **Irel)
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(bool is_analyze)
bool vacuum_is_permitted_for_relation(Oid relid, Form_pg_class reltuple, bits32 options)
void vac_update_relstats(Relation relation, BlockNumber num_pages, double num_tuples, BlockNumber num_all_visible_pages, BlockNumber num_all_frozen_pages, bool hasindex, TransactionId frozenxid, MultiXactId minmulti, bool *frozenxid_updated, bool *minmulti_updated, bool in_outer_xact)
Datum(* AnalyzeAttrFetchFunc)(VacAttrStatsP stats, int rownum, bool *isNull)
static Size VARSIZE_ANY(const void *PTR)
void visibilitymap_count(Relation rel, BlockNumber *all_visible, BlockNumber *all_frozen)
void CommandCounterIncrement(void)