Versions in this module Expand all Collapse all v1 v1.0.0 Aug 23, 2023 v0 v0.1.0 Aug 23, 2023 Changes in this version + const DumpAll + const DumpDelta + const MaxPartitionMergeBatchSize + const StatsOwnerKey + const StatsPrompt + const StatsStatusAnalyzed + const StatsStatusDeleted + const StatsStatusInited + const TiDBGlobalStats + var AutoAnalyzeMinCnt int64 = 1000 + var DumpStatsDeltaRatio = 1 / 10000.0 + var MinLogErrorRate = atomic.NewFloat64(0.5) + var MinLogScanCount = atomic.NewInt64(1000) + func DurationToTS(d time.Duration) uint64 + func JSONTableToBlocks(jsTable *JSONTable, blockSize int) ([][]byte, error) + func MergeGlobalStatsTopNByConcurrency(mergeConcurrency, mergeBatchSize int, wrapper *statistics.StatsWrapper, ...) (*statistics.TopN, []statistics.TopNMeta, []*statistics.Histogram, error) + func NeedAnalyzeTable(tbl *statistics.Table, limit time.Duration, autoAnalyzeRatio float64) (bool, string) + func SaveTableStatsToStorage(sctx sessionctx.Context, results *statistics.AnalyzeResults, ...) (err error) + func TableAnalyzed(tbl *statistics.Table) bool + func TableStatsFromJSON(tableInfo *model.TableInfo, physicalID int64, jsonTbl *JSONTable) (*statistics.Table, error) + type GlobalIndexID struct + IndexID int64 + TableID int64 + type GlobalStats struct + Cms []*statistics.CMSketch + Count int64 + Fms []*statistics.FMSketch + Hg []*statistics.Histogram + ModifyCount int64 + Num int + TopN []*statistics.TopN + type Handle struct + StatsLoad StatsLoad + func NewHandle(ctx, initStatsCtx sessionctx.Context, lease time.Duration, pool sessionPool, ...) (*Handle, error) + func (h *Handle) AddLockedTables(tids []int64, pids []int64, tables []*ast.TableName) (string, error) + func (h *Handle) AppendNeededItem(task *NeededItemTask, timeout time.Duration) error + func (h *Handle) BuildExtendedStats(tableID int64, cols []*model.ColumnInfo, ...) (*statistics.ExtendedStatsColl, error) + func (h *Handle) CheckAnalyzeVersion(tblInfo *model.TableInfo, physicalIDs []int64, version *int) bool + func (h *Handle) CheckHistoricalStatsEnable() (enable bool, err error) + func (h *Handle) Clear() + func (h *Handle) CollectColumnsInExtendedStats(tableID int64) ([]int64, error) + func (h *Handle) CurrentPruneMode() variable.PartitionPruneMode + func (h *Handle) DDLEventCh() chan *util.Event + func (h *Handle) DeleteAnalyzeJobs(updateTime time.Time) error + func (h *Handle) DeleteTableStatsFromKV(statsIDs []int64) (err error) + func (h *Handle) DumpColStatsUsageToKV() error + func (h *Handle) DumpFeedbackForIndex(q *statistics.QueryFeedback, t *statistics.Table) error + func (h *Handle) DumpFeedbackToKV(fb *statistics.QueryFeedback) error + func (h *Handle) DumpIndexUsageToKV() error + func (h *Handle) DumpStatsDeltaToKV(mode dumpMode) error + func (h *Handle) DumpStatsFeedbackToKV() error + func (h *Handle) DumpStatsToJSON(dbName string, tableInfo *model.TableInfo, ...) (*JSONTable, error) + func (h *Handle) DumpStatsToJSONBySnapshot(dbName string, tableInfo *model.TableInfo, snapshot uint64, ...) (*JSONTable, error) + func (h *Handle) FlushStats() + func (h *Handle) GCIndexUsage() error + func (h *Handle) GCStats(is infoschema.InfoSchema, ddlLease time.Duration) error + func (h *Handle) GetMemConsumed() (size int64) + func (h *Handle) GetPartitionStats(tblInfo *model.TableInfo, pid int64, opts ...TableStatsOpt) *statistics.Table + func (h *Handle) GetPredicateColumns(tableID int64) ([]int64, error) + func (h *Handle) GetQueryFeedback() *statistics.QueryFeedbackMap + func (h *Handle) GetStatsCacheFrontTable() int64 + func (h *Handle) GetTableLockedAndClearForTest() []int64 + func (h *Handle) GetTableStats(tblInfo *model.TableInfo, opts ...TableStatsOpt) *statistics.Table + func (h *Handle) HandleAutoAnalyze(is infoschema.InfoSchema) (analyzed bool) + func (h *Handle) HandleDDLEvent(t *util.Event) error + func (h *Handle) HandleOneTask(lastTask *NeededItemTask, readerCtx *StatsReaderContext, ...) (task *NeededItemTask, err error) + func (h *Handle) HandleUpdateStats(is infoschema.InfoSchema) error + func (h *Handle) InitStats(is infoschema.InfoSchema) (err error) + func (h *Handle) InsertAnalyzeJob(job *statistics.AnalyzeJob, instance string, procID uint64) error + func (h *Handle) InsertExtendedStats(statsName string, colIDs []int64, tp int, tableID int64, ifNotExists bool) (err error) + func (h *Handle) IsTableLocked(tableID int64) bool + func (h *Handle) LastUpdateVersion() uint64 + func (h *Handle) Lease() time.Duration + func (h *Handle) LoadColumnStatsUsage(loc *time.Location) (map[model.TableItemID]colStatsTimeInfo, error) + func (h *Handle) LoadLockedTables() error + func (h *Handle) LoadNeededHistograms() (err error) + func (h *Handle) LoadStatsFromJSON(is infoschema.InfoSchema, jsonTbl *JSONTable) error + func (h *Handle) MarkExtendedStatsDeleted(statsName string, tableID int64, ifExists bool) (err error) + func (h *Handle) MergePartitionStats2GlobalStatsByTableID(sc sessionctx.Context, opts map[ast.AnalyzeOptionType]uint64, ...) (globalStats *GlobalStats, err error) + func (h *Handle) NewSessionIndexUsageCollector() *SessionIndexUsageCollector + func (h *Handle) NewSessionStatsCollector() *SessionStatsCollector + func (h *Handle) RecalculateExpectCount(q *statistics.QueryFeedback, enablePseudoForOutdatedStats bool) error + func (h *Handle) RecordHistoricalStatsToStorage(dbName string, tableInfo *model.TableInfo) (uint64, error) + func (h *Handle) RefreshVars() error + func (h *Handle) ReloadExtendedStatistics() error + func (h *Handle) RemoveLockedTables(tids []int64, pids []int64, tables []*ast.TableName) (string, error) + func (h *Handle) SaveExtendedStatsToStorage(tableID int64, extStats *statistics.ExtendedStatsColl, isLoad bool) (err error) + func (h *Handle) SaveMetaToStorage(tableID, count, modifyCount int64) (err error) + func (h *Handle) SaveStatsToStorage(tableID int64, count, modifyCount int64, isIndex int, hg *statistics.Histogram, ...) (err error) + func (h *Handle) SaveTableStatsToStorage(results *statistics.AnalyzeResults, analyzeSnapshot bool) (err error) + func (h *Handle) SendLoadRequests(sc *stmtctx.StatementContext, neededHistItems []model.TableItemID, ...) error + func (h *Handle) SetLastUpdateVersion(version uint64) + func (h *Handle) SetLease(lease time.Duration) + func (h *Handle) SetStatsCacheCapacity(c int64) + func (h *Handle) StatsMetaCountAndModifyCount(tableID int64) (int64, int64, error) + func (h *Handle) SubLoadWorker(ctx sessionctx.Context, exit chan struct{}, exitWg *util.WaitGroupWrapper) + func (h *Handle) SyncWaitStatsLoad(sc *stmtctx.StatementContext) error + func (h *Handle) TableStatsFromStorage(tableInfo *model.TableInfo, physicalID int64, loadAll bool, snapshot uint64) (_ *statistics.Table, err error) + func (h *Handle) Update(is infoschema.InfoSchema, opts ...TableStatsOpt) error + func (h *Handle) UpdateErrorRate(is infoschema.InfoSchema) + func (h *Handle) UpdateSessionVar() error + func (h *Handle) UpdateStatsByLocalFeedback(is infoschema.InfoSchema) + type IndexUsageInformation struct + LastUsedAt string + QueryCount int64 + RowsSelected int64 + type JSONTable struct + Columns map[string]*jsonColumn + Count int64 + DatabaseName string + ExtStats []*jsonExtendedStats + Indices map[string]*jsonColumn + ModifyCount int64 + Partitions map[string]*JSONTable + TableName string + func BlocksToJSONTable(blocks [][]byte) (*JSONTable, error) + func GenJSONTableFromStats(dbName string, tableInfo *model.TableInfo, tbl *statistics.Table) (*JSONTable, error) + type NeededItemTask struct + ResultCh chan stmtctx.StatsLoadResult + TableItemID model.TableItemID + ToTimeout time.Time + type SessionIndexUsageCollector struct + func (s *SessionIndexUsageCollector) Delete() + func (s *SessionIndexUsageCollector) Update(tableID int64, indexID int64, value *IndexUsageInformation) + type SessionStatsCollector struct + func (s *SessionStatsCollector) Delete() + func (s *SessionStatsCollector) StoreQueryFeedback(feedback interface{}, h *Handle, enablePseudoForOutdatedStats bool) error + func (s *SessionStatsCollector) Update(id int64, delta int64, count int64, colSize *map[int64]int64) + func (s *SessionStatsCollector) UpdateColStatsUsage(colMap colStatsUsageMap) + type StatsLoad struct + NeededItemsCh chan *NeededItemTask + SubCtxs []sessionctx.Context + TimeoutItemsCh chan *NeededItemTask + WorkingColMap map[model.TableItemID][]chan stmtctx.StatsLoadResult + type StatsReaderContext struct + type TableStatsOpt func(*tableStatsOption) + func WithTableStatsByQuery() TableStatsOpt