Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef VACUUM_H
00015 #define VACUUM_H
00016
00017 #include "access/htup.h"
00018 #include "catalog/pg_statistic.h"
00019 #include "catalog/pg_type.h"
00020 #include "nodes/parsenodes.h"
00021 #include "storage/buf.h"
00022 #include "storage/lock.h"
00023 #include "utils/relcache.h"
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 typedef struct VacAttrStats *VacAttrStatsP;
00060
00061 typedef Datum (*AnalyzeAttrFetchFunc) (VacAttrStatsP stats, int rownum,
00062 bool *isNull);
00063
00064 typedef void (*AnalyzeAttrComputeStatsFunc) (VacAttrStatsP stats,
00065 AnalyzeAttrFetchFunc fetchfunc,
00066 int samplerows,
00067 double totalrows);
00068
00069 typedef struct VacAttrStats
00070 {
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 Form_pg_attribute attr;
00082 Oid attrtypid;
00083 int32 attrtypmod;
00084 Form_pg_type attrtype;
00085 MemoryContext anl_context;
00086
00087
00088
00089
00090
00091 AnalyzeAttrComputeStatsFunc compute_stats;
00092 int minrows;
00093 void *extra_data;
00094
00095
00096
00097
00098
00099 bool stats_valid;
00100 float4 stanullfrac;
00101 int32 stawidth;
00102 float4 stadistinct;
00103 int16 stakind[STATISTIC_NUM_SLOTS];
00104 Oid staop[STATISTIC_NUM_SLOTS];
00105 int numnumbers[STATISTIC_NUM_SLOTS];
00106 float4 *stanumbers[STATISTIC_NUM_SLOTS];
00107 int numvalues[STATISTIC_NUM_SLOTS];
00108 Datum *stavalues[STATISTIC_NUM_SLOTS];
00109
00110
00111
00112
00113
00114
00115
00116 Oid statypid[STATISTIC_NUM_SLOTS];
00117 int16 statyplen[STATISTIC_NUM_SLOTS];
00118 bool statypbyval[STATISTIC_NUM_SLOTS];
00119 char statypalign[STATISTIC_NUM_SLOTS];
00120
00121
00122
00123
00124
00125 int tupattnum;
00126 HeapTuple *rows;
00127 TupleDesc tupDesc;
00128 Datum *exprvals;
00129 bool *exprnulls;
00130 int rowstride;
00131 } VacAttrStats;
00132
00133
00134
00135 extern PGDLLIMPORT int default_statistics_target;
00136
00137 extern int vacuum_freeze_min_age;
00138 extern int vacuum_freeze_table_age;
00139
00140
00141
00142 extern void vacuum(VacuumStmt *vacstmt, Oid relid, bool do_toast,
00143 BufferAccessStrategy bstrategy, bool for_wraparound, bool isTopLevel);
00144 extern void vac_open_indexes(Relation relation, LOCKMODE lockmode,
00145 int *nindexes, Relation **Irel);
00146 extern void vac_close_indexes(int nindexes, Relation *Irel, LOCKMODE lockmode);
00147 extern double vac_estimate_reltuples(Relation relation, bool is_analyze,
00148 BlockNumber total_pages,
00149 BlockNumber scanned_pages,
00150 double scanned_tuples);
00151 extern void vac_update_relstats(Relation relation,
00152 BlockNumber num_pages,
00153 double num_tuples,
00154 BlockNumber num_all_visible_pages,
00155 bool hasindex,
00156 TransactionId frozenxid,
00157 MultiXactId minmulti);
00158 extern void vacuum_set_xid_limits(int freeze_min_age, int freeze_table_age,
00159 bool sharedRel,
00160 TransactionId *oldestXmin,
00161 TransactionId *freezeLimit,
00162 TransactionId *freezeTableLimit,
00163 MultiXactId *multiXactFrzLimit);
00164 extern void vac_update_datfrozenxid(void);
00165 extern void vacuum_delay_point(void);
00166
00167
00168 extern void lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
00169 BufferAccessStrategy bstrategy);
00170
00171
00172 extern void analyze_rel(Oid relid, VacuumStmt *vacstmt,
00173 BufferAccessStrategy bstrategy);
00174 extern bool std_typanalyze(VacAttrStats *stats);
00175 extern double anl_random_fract(void);
00176 extern double anl_init_selection_state(int n);
00177 extern double anl_get_next_S(double t, int n, double *stateptr);
00178
00179 #endif