#include "postgres.h"
#include "access/detoast.h"
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/table.h"
#include "catalog/indexing.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
#include "commands/defrem.h"
#include "commands/progress.h"
#include "executor/executor.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/optimizer.h"
#include "parser/parsetree.h"
#include "pgstat.h"
#include "postmaster/autovacuum.h"
#include "statistics/extended_stats_internal.h"
#include "statistics/statistics.h"
#include "utils/acl.h"
#include "utils/array.h"
#include "utils/attoptcache.h"
#include "utils/builtins.h"
#include "utils/datum.h"
#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/selfuncs.h"
#include "utils/syscache.h"
Go to the source code of this file.
Definition at line 58 of file extended_stats.c.
Definition at line 938 of file extended_stats.c.
References Assert(), attnum, AttributeNumberIsValid, bms_next_member(), bms_num_members(), i, j, MaxAttrNumber, and palloc().
Definition at line 2247 of file extended_stats.c.
References examine_expression(), AnlExprData::expr, idx(), lfirst, list_length(), palloc0(), and AnlExprData::vacattrstat.
Referenced by BuildRelationExtStatistics().
Definition at line 983 of file extended_stats.c.
References Assert(), attlen, attnum, data, get_typlen(), i, idx(), items, j, len, MAXALIGN, multi_sort_compare(), nitems, palloc(), palloc0(), pfree(), PG_DETOAST_DATUM, PointerGetDatum(), qsort_interruptible(), toast_raw_datum_size(), value, values, and WIDTH_THRESHOLD.
Referenced by dependency_degree(), and statext_mcv_build().
Definition at line 111 of file extended_stats.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, AmAutoVacuumWorkerProcess, bms_num_members(), build_expr_data(), compute_expr_stats(), CurrentMemoryContext, data, elog, ereport, errcode(), errmsg(), ERROR, errtable(), fetch_statentries_for_relation(), get_namespace_name(), lfirst, lfirst_int, list_free(), list_length(), lookup_var_attr_stats(), make_build_data(), MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), NIL, pgstat_progress_update_multi_param(), pgstat_progress_update_param(), PROGRESS_ANALYZE_EXT_STATS_COMPUTED, PROGRESS_ANALYZE_EXT_STATS_TOTAL, PROGRESS_ANALYZE_PHASE, PROGRESS_ANALYZE_PHASE_COMPUTE_EXT_STATS, RelationData::rd_rel, RelationGetRelationName, RelationGetRelid, RowExclusiveLock, serialize_expr_stats(), statext_compute_stattarget(), statext_dependencies_build(), statext_mcv_build(), statext_ndistinct_build(), statext_store(), table_close(), table_open(), val, and WARNING.
Referenced by do_analyze_rel().
Definition at line 1207 of file extended_stats.c.
References bms_add_members(), bms_free(), bms_is_subset(), bms_num_members(), StatisticExtInfo::exprs, i, StatisticExtInfo::inherit, StatisticExtInfo::keys, StatisticExtInfo::kind, lfirst, list_length(), stat_covers_expressions(), and STATS_MAX_DIMENSIONS.
Referenced by statext_mcv_clauselist_selectivity().
Definition at line 924 of file extended_stats.c.
References a, ApplySortComparator(), and b.
Referenced by compare_scalars_simple(), and statext_mcv_serialize().
Definition at line 916 of file extended_stats.c.
References a, arg, b, and compare_datums_simple().
Referenced by statext_mcv_serialize().
Definition at line 2088 of file extended_stats.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), VacAttrStats::attrtype, VacAttrStats::compute_stats, CreateExecutorState(), CurrentMemoryContext, datumCopy(), ExprContext::ecxt_scantuple, ExecDropSingleTupleTableSlot(), ExecEvalExprSwitchContext(), ExecPrepareExpr(), ExecStoreHeapTuple(), AnlExprData::expr, expr_fetch_func(), VacAttrStats::exprnulls, VacAttrStats::exprvals, FreeExecutorState(), get_attribute_options(), GetPerTupleExprContext, i, MakeSingleTupleTableSlot(), MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), AttributeOpts::n_distinct, palloc(), RelationData::rd_id, RelationGetDescr, ResetExprContext, VacAttrStats::rowstride, VacAttrStats::stadistinct, TTSOpsHeapTuple, VacAttrStats::tupattnum, and AnlExprData::vacattrstat.
Referenced by BuildRelationExtStatistics().
Definition at line 262 of file extended_stats.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, bms_num_members(), CurrentMemoryContext, fetch_statentries_for_relation(), lfirst, lookup_var_attr_stats(), MemoryContextDelete(), MemoryContextSwitchTo(), RelationGetRelid, RowExclusiveLock, statext_compute_stattarget(), table_close(), and table_open().
Referenced by do_analyze_rel().
Definition at line 525 of file extended_stats.c.
References VacAttrStats::anl_context, VacAttrStats::attrcollid, VacAttrStats::attrtype, VacAttrStats::attrtypid, VacAttrStats::attrtypmod, VacAttrStats::attstattarget, VacAttrStats::compute_stats, DatumGetBool(), elog, ERROR, exprCollation(), exprType(), exprTypmod(), GETSTRUCT(), heap_freetuple(), HeapTupleIsValid, i, InvalidAttrNumber, VacAttrStats::minrows, ObjectIdGetDatum(), OidFunctionCall1, OidIsValid, palloc0(), pfree(), PointerGetDatum(), SearchSysCacheCopy1, STATISTIC_NUM_SLOTS, VacAttrStats::statypalign, VacAttrStats::statypbyval, VacAttrStats::statypid, VacAttrStats::statyplen, std_typanalyze(), and VacAttrStats::tupattnum.
Referenced by lookup_var_attr_stats().
Definition at line 604 of file extended_stats.c.
References VacAttrStats::anl_context, Assert(), VacAttrStats::attrcollid, VacAttrStats::attrtype, VacAttrStats::attrtypid, VacAttrStats::attrtypmod, VacAttrStats::attstattarget, VacAttrStats::compute_stats, CurrentMemoryContext, DatumGetBool(), elog, ERROR, exprCollation(), exprType(), exprTypmod(), GETSTRUCT(), heap_freetuple(), HeapTupleIsValid, i, InvalidAttrNumber, VacAttrStats::minrows, ObjectIdGetDatum(), OidFunctionCall1, OidIsValid, palloc0(), pfree(), PointerGetDatum(), SearchSysCacheCopy1, STATISTIC_NUM_SLOTS, VacAttrStats::statypalign, VacAttrStats::statypbyval, VacAttrStats::statypid, VacAttrStats::statyplen, std_typanalyze(), and VacAttrStats::tupattnum.
Referenced by build_expr_data(), and make_build_data().
Definition at line 2033 of file extended_stats.c.
References arg, generate_unaccent_rules::args, Assert(), IsA, linitial, list_length(), and lsecond.
Referenced by mcv_get_match_bitmap(), and statext_is_compatible_clause_internal().
Definition at line 2231 of file extended_stats.c.
References VacAttrStats::exprnulls, VacAttrStats::exprvals, i, and VacAttrStats::rowstride.
Referenced by compute_expr_stats().
Definition at line 419 of file extended_stats.c.
References ARR_DATA_PTR, ARR_DIMS, ARR_ELEMTYPE, ARR_HASNULL, ARR_NDIM, Assert(), bms_add_member(), BTEqualStrategyNumber, StatExtEntry::columns, DatumGetArrayTypeP, DatumGetInt16(), elog, ERROR, eval_const_expressions(), StatExtEntry::exprs, fix_opfuncids(), get_namespace_name(), GETSTRUCT(), HeapTupleIsValid, i, lappend(), lappend_int(), StatExtEntry::name, NameStr, NIL, ObjectIdGetDatum(), palloc0(), pfree(), pstrdup(), ScanKeyInit(), StatExtEntry::schema, StatExtEntry::statOid, StatExtEntry::stattarget, stringToNode(), SysCacheGetAttr(), SysCacheGetAttrNotNull(), systable_beginscan(), systable_endscan(), systable_getnext(), TextDatumGetCString, and StatExtEntry::types.
Referenced by BuildRelationExtStatistics(), and ComputeExtStatisticsRows().
Definition at line 1116 of file extended_stats.c.
References lfirst.
Referenced by dependencies_clauselist_selectivity(), and statext_mcv_clauselist_selectivity().
Definition at line 690 of file extended_stats.c.
References bms_next_member(), bms_num_members(), examine_attribute(), i, j, lfirst, list_length(), palloc(), pfree(), VacAttrStats::tupDesc, and x.
Referenced by BuildRelationExtStatistics(), and ComputeExtStatisticsRows().
Definition at line 2449 of file extended_stats.c.
References Assert(), StatsBuildData::attnums, bms_next_member(), bms_num_members(), CreateExecutorState(), ExprContext::ecxt_scantuple, examine_expression(), ExecDropSingleTupleTableSlot(), ExecEvalExpr(), ExecPrepareExprList(), ExecStoreHeapTuple(), FreeExecutorState(), GetPerTupleExprContext, heap_getattr(), i, idx(), len, lfirst, list_length(), MakeSingleTupleTableSlot(), MAXALIGN, StatsBuildData::nattnums, NIL, StatsBuildData::nulls, StatsBuildData::numrows, palloc(), RelationGetDescr, ResetExprContext, StatsBuildData::stats, TTSOpsHeapTuple, VacAttrStats::tupDesc, and StatsBuildData::values.
Referenced by BuildRelationExtStatistics().
Definition at line 848 of file extended_stats.c.
References CurrentMemoryContext, oper(), PrepareSortSupportFromOrderingOp(), MultiSortSupportData::ssup, SortSupportData::ssup_collation, SortSupportData::ssup_cxt, and SortSupportData::ssup_nulls_first.
Referenced by build_mss(), dependency_degree(), and ndistinct_for_combination().
Definition at line 862 of file extended_stats.c.
References a, ApplySortComparator(), arg, b, compare(), i, SortItem::isnull, MultiSortSupportData::ndims, MultiSortSupportData::ssup, and SortItem::values.
Referenced by build_distinct_groups(), build_sorted_items(), count_distinct_groups(), ndistinct_for_combination(), and statext_mcv_build().
Definition at line 887 of file extended_stats.c.
References a, ApplySortComparator(), b, and MultiSortSupportData::ssup.
Referenced by dependency_degree().
Definition at line 896 of file extended_stats.c.
References a, ApplySortComparator(), b, MultiSortSupportData::ssup, and start.
Referenced by dependency_degree().
Definition at line 829 of file extended_stats.c.
References Assert(), MultiSortSupportData::ndims, and palloc0().
Referenced by build_mss(), dependency_degree(), and ndistinct_for_combination().
Definition at line 2272 of file extended_stats.c.
References accumArrayResult(), BoolGetDatum(), construct_array(), construct_array_builtin(), CurrentMemoryContext, ereport, errcode(), errmsg(), ERROR, Float4GetDatum(), get_rel_type_id(), heap_copy_tuple_as_datum(), heap_form_tuple(), i, Int16GetDatum(), Int32GetDatum(), InvalidAttrNumber, InvalidOid, makeArrayResult(), VacAttrStats::numnumbers, VacAttrStats::numvalues, ObjectIdGetDatum(), OidIsValid, palloc(), PointerGetDatum(), RelationGetDescr, RowExclusiveLock, VacAttrStats::stacoll, VacAttrStats::stadistinct, VacAttrStats::stakind, VacAttrStats::stanullfrac, VacAttrStats::stanumbers, VacAttrStats::staop, STATISTIC_NUM_SLOTS, VacAttrStats::stats_valid, VacAttrStats::statypalign, VacAttrStats::statypbyval, VacAttrStats::statypid, VacAttrStats::statyplen, VacAttrStats::stavalues, VacAttrStats::stawidth, table_close(), table_open(), AnlExprData::vacattrstat, and values.
Referenced by BuildRelationExtStatistics().
Definition at line 1166 of file extended_stats.c.
References bms_add_member(), lfirst, and stat_find_expression().
Referenced by choose_best_statistics(), and statext_mcv_clauselist_selectivity().
Definition at line 1139 of file extended_stats.c.
References equal(), idx(), and lfirst.
Referenced by stat_covers_expressions().
Definition at line 1982 of file extended_stats.c.
References dependencies_clauselist_selectivity(), root, and statext_mcv_clauselist_selectivity().
Referenced by clauselist_selectivity_ext(), and clauselist_selectivity_or().
Definition at line 344 of file extended_stats.c.
References Assert(), VacAttrStats::attstattarget, default_statistics_target, i, and MAX_STATISTICS_TARGET.
Referenced by BuildRelationExtStatistics(), and ComputeExtStatisticsRows().
Definition at line 2402 of file extended_stats.c.
References BoolGetDatum(), DatumGetExpandedArray(), DatumGetHeapTupleHeader, deconstruct_expanded_array(), ExpandedArrayHeader::dvalues, elog, ERROR, heap_copytuple(), HeapTupleHeaderGetDatumLength(), HeapTupleIsValid, idx(), InvalidOid, ItemPointerSetInvalid(), ObjectIdGetDatum(), ReleaseSysCache(), SearchSysCache2(), SysCacheGetAttr(), HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, HeapTupleData::t_tableOid, and value.
Referenced by examine_variable().
Definition at line 1556 of file extended_stats.c.
References all_rows_selectable(), BoolExpr::args, attnum, bms_add_member(), bms_get_singleton_member(), bms_next_member(), RestrictInfo::clause, FirstLowInvalidHeapAttributeNumber, is_andclause(), IsA, lfirst, NIL, pull_varattnos(), root, statext_is_compatible_clause(), and statext_is_compatible_clause_internal().
Referenced by statext_is_compatible_clause(), and statext_mcv_clauselist_selectivity().
Definition at line 1329 of file extended_stats.c.
References arg, NullTest::arg, OpExpr::args, ScalarArrayOpExpr::args, BoolExpr::args, AttrNumberIsForUserDefinedAttr, bms_add_member(), examine_opclause_args(), get_func_leakproof(), get_opcode(), get_oprrest(), is_andclause(), is_notclause(), is_opclause(), is_orclause(), IsA, lappend(), lfirst, list_length(), OpExpr::opno, ScalarArrayOpExpr::opno, root, statext_is_compatible_clause_internal(), Var::varattno, Var::varlevelsup, and Var::varno.
Referenced by statext_is_compatible_clause(), and statext_is_compatible_clause_internal().
Definition at line 386 of file extended_stats.c.
References attnum, elog, ERROR, heap_attisnull(), and type.
Referenced by get_relation_statistics_worker().
Definition at line 1694 of file extended_stats.c.
References Assert(), bms_add_member(), bms_free(), bms_is_member(), bms_is_subset(), bms_membership(), BMS_SINGLETON, choose_best_statistics(), CLAMP_PROBABILITY, clause_selectivity_ext(), clauselist_selectivity_ext(), has_stats_of_kind(), RangeTblEntry::inh, lappend(), lfirst, list_free(), list_length(), mcv_clause_selectivity_or(), mcv_clauselist_selectivity(), mcv_combine_selectivities(), NIL, palloc(), planner_rt_fetch, RelOptInfo::relid, root, stat, stat_covers_expressions(), statext_is_compatible_clause(), statext_mcv_load(), and RelOptInfo::statlist.
Referenced by statext_clauselist_selectivity().
Definition at line 759 of file extended_stats.c.
References BoolGetDatum(), CatalogTupleInsert(), data, heap_form_tuple(), heap_freetuple(), ObjectIdGetDatum(), PointerGetDatum(), RelationGetDescr, RemoveStatisticsDataById(), RowExclusiveLock, statext_dependencies_serialize(), statext_mcv_serialize(), statext_ndistinct_serialize(), table_close(), table_open(), and values.
Referenced by BuildRelationExtStatistics().