Documentation ¶
Index ¶
- Constants
- Variables
- func CallWithSCtx(pool util.SessionPool, f func(sctx sessionctx.Context) error, flags ...int) (err error)
- func DurationToTS(d time.Duration) uint64
- func Exec(sctx sessionctx.Context, sql string, args ...any) (sqlexec.RecordSet, error)
- func ExecRows(sctx sessionctx.Context, sql string, args ...any) (rows []chunk.Row, fields []*resolve.ResultField, err error)
- func ExecRowsWithCtx(ctx context.Context, sctx sessionctx.Context, sql string, args ...any) (rows []chunk.Row, fields []*resolve.ResultField, err error)
- func ExecWithCtx(ctx context.Context, sctx sessionctx.Context, sql string, args ...any) (sqlexec.RecordSet, error)
- func ExecWithOpts(sctx sessionctx.Context, opts []sqlexec.OptionFuncAlias, sql string, ...) (rows []chunk.Row, fields []*resolve.ResultField, err error)
- func GetCurrentPruneMode(pool util.SessionPool) (mode string, err error)
- func GetStartTS(sctx sessionctx.Context) (uint64, error)
- func IsSpecialGlobalIndex(idx *model.IndexInfo, tblInfo *model.TableInfo) bool
- func UpdateSCtxVarsForStats(sctx sessionctx.Context) error
- func WrapTxn(sctx sessionctx.Context, f func(sctx sessionctx.Context) error) (err error)
- type AutoAnalyzeProcIDGenerator
- type AutoAnalyzeTracker
- type JSONColumn
- type JSONExtendedStats
- type JSONPredicateColumn
- type JSONTable
- type LeaseGetter
- type Pool
- type TableInfoGetter
Constants ¶
const ( // StatsMetaHistorySourceAnalyze indicates stats history meta source from analyze StatsMetaHistorySourceAnalyze = "analyze" // StatsMetaHistorySourceLoadStats indicates stats history meta source from load stats StatsMetaHistorySourceLoadStats = "load stats" // StatsMetaHistorySourceFlushStats indicates stats history meta source from flush stats StatsMetaHistorySourceFlushStats = "flush stats" // StatsMetaHistorySourceSchemaChange indicates stats history meta source from schema change StatsMetaHistorySourceSchemaChange = "schema change" // StatsMetaHistorySourceExtendedStats indicates stats history meta source from extended stats StatsMetaHistorySourceExtendedStats = "extended stats" // TiDBGlobalStats represents the global-stats for a partitioned table. TiDBGlobalStats = "global" )
Variables ¶
var ( // UseCurrentSessionOpt to make sure the sql is executed in current session. UseCurrentSessionOpt = []sqlexec.OptionFuncAlias{sqlexec.ExecOptionUseCurSession} // StatsCtx is used to mark the request is from stats module. StatsCtx = kv.WithInternalSourceType(context.Background(), kv.InternalTxnStats) )
var (
// FlagWrapTxn indicates whether to wrap a transaction.
FlagWrapTxn = 0
)
var GlobalAutoAnalyzeProcessList = newGlobalAutoAnalyzeProcessList()
GlobalAutoAnalyzeProcessList is used to track the auto analyze process.
Functions ¶
func CallWithSCtx ¶
func CallWithSCtx(pool util.SessionPool, f func(sctx sessionctx.Context) error, flags ...int) (err error)
CallWithSCtx allocates a sctx from the pool and call the f().
func DurationToTS ¶
DurationToTS converts duration to timestamp.
func ExecRows ¶
func ExecRows(sctx sessionctx.Context, sql string, args ...any) (rows []chunk.Row, fields []*resolve.ResultField, err error)
ExecRows is a helper function to execute sql and return rows and fields.
func ExecRowsWithCtx ¶
func ExecRowsWithCtx( ctx context.Context, sctx sessionctx.Context, sql string, args ...any, ) (rows []chunk.Row, fields []*resolve.ResultField, err error)
ExecRowsWithCtx is a helper function to execute sql and return rows and fields.
func ExecWithCtx ¶
func ExecWithCtx( ctx context.Context, sctx sessionctx.Context, sql string, args ...any, ) (sqlexec.RecordSet, error)
ExecWithCtx is a helper function to execute sql and return RecordSet.
func ExecWithOpts ¶
func ExecWithOpts(sctx sessionctx.Context, opts []sqlexec.OptionFuncAlias, sql string, args ...any) (rows []chunk.Row, fields []*resolve.ResultField, err error)
ExecWithOpts is a helper function to execute sql and return rows and fields.
func GetCurrentPruneMode ¶
func GetCurrentPruneMode(pool util.SessionPool) (mode string, err error)
GetCurrentPruneMode returns the current latest partitioning table prune mode.
func GetStartTS ¶
func GetStartTS(sctx sessionctx.Context) (uint64, error)
GetStartTS gets the start ts from current transaction.
func IsSpecialGlobalIndex ¶
IsSpecialGlobalIndex checks a index is a special global index or not. A special global index is one that is a global index and has virtual generated columns or prefix columns.
func UpdateSCtxVarsForStats ¶
func UpdateSCtxVarsForStats(sctx sessionctx.Context) error
UpdateSCtxVarsForStats updates all necessary variables that may affect the behavior of statistics.
func WrapTxn ¶
func WrapTxn(sctx sessionctx.Context, f func(sctx sessionctx.Context) error) (err error)
WrapTxn uses a transaction here can let different SQLs in this operation have the same data visibility.
Types ¶
type AutoAnalyzeProcIDGenerator ¶
type AutoAnalyzeProcIDGenerator interface { // AutoAnalyzeProcID generates an analyze ID. AutoAnalyzeProcID() uint64 ReleaseAutoAnalyzeProcID(uint64) }
AutoAnalyzeProcIDGenerator is used to generate auto analyze proc ID.
func NewGenerator ¶
func NewGenerator(autoAnalyzeProcIDGetter func() uint64, releaseAutoAnalyzeProcID func(uint64)) AutoAnalyzeProcIDGenerator
NewGenerator creates a new Generator.
type AutoAnalyzeTracker ¶
type AutoAnalyzeTracker struct {
// contains filtered or unexported fields
}
AutoAnalyzeTracker is used to track the auto analyze process.
func NewAutoAnalyzeTracker ¶
func NewAutoAnalyzeTracker(track func(id uint64, ctx sysproctrack.TrackProc) error, untrack func(id uint64)) *AutoAnalyzeTracker
NewAutoAnalyzeTracker creates a new AutoAnalyzeTracker.
func (*AutoAnalyzeTracker) Track ¶
func (t *AutoAnalyzeTracker) Track(id uint64, ctx sysproctrack.TrackProc) error
Track is used to track the auto analyze process.
func (*AutoAnalyzeTracker) UnTrack ¶
func (t *AutoAnalyzeTracker) UnTrack(id uint64)
UnTrack is used to untrack the auto analyze process.
type JSONColumn ¶
type JSONColumn struct { Histogram *tipb.Histogram `json:"histogram"` CMSketch *tipb.CMSketch `json:"cm_sketch"` FMSketch *tipb.FMSketch `json:"fm_sketch"` // StatsVer is a pointer here since the old version json file would not contain version information. StatsVer *int64 `json:"stats_ver"` NullCount int64 `json:"null_count"` TotColSize int64 `json:"tot_col_size"` LastUpdateVersion uint64 `json:"last_update_version"` Correlation float64 `json:"correlation"` }
JSONColumn is used for dumping statistics.
func (*JSONColumn) TotalMemoryUsage ¶
func (col *JSONColumn) TotalMemoryUsage() (size int64)
TotalMemoryUsage returns the total memory usage of this column.
type JSONExtendedStats ¶
type JSONExtendedStats struct { StatsName string `json:"stats_name"` StringVals string `json:"string_vals"` ColIDs []int64 `json:"cols"` ScalarVals float64 `json:"scalar_vals"` Tp uint8 `json:"type"` }
JSONExtendedStats is used for dumping extended statistics.
type JSONPredicateColumn ¶
type JSONPredicateColumn struct { LastUsedAt *string `json:"last_used_at"` LastAnalyzedAt *string `json:"last_analyzed_at"` ID int64 `json:"id"` }
JSONPredicateColumn contains the information of the columns used in the predicate.
type JSONTable ¶
type JSONTable struct { Columns map[string]*JSONColumn `json:"columns"` Indices map[string]*JSONColumn `json:"indices"` Partitions map[string]*JSONTable `json:"partitions"` DatabaseName string `json:"database_name"` TableName string `json:"table_name"` ExtStats []*JSONExtendedStats `json:"ext_stats"` PredicateColumns []*JSONPredicateColumn `json:"predicate_columns"` Count int64 `json:"count"` ModifyCount int64 `json:"modify_count"` Version uint64 `json:"version"` IsHistoricalStats bool `json:"is_historical_stats"` }
JSONTable is used for dumping statistics.
type LeaseGetter ¶
type LeaseGetter interface { // Lease returns the stats lease. Lease() time.Duration // SetLease sets the stats lease. Only used for test. SetLease(lease time.Duration) }
LeaseGetter is used to get the stats lease.
func NewLeaseGetter ¶
func NewLeaseGetter(lease time.Duration) LeaseGetter
NewLeaseGetter creates a new LeaseGetter.
type Pool ¶
type Pool interface { // GPool returns the goroutine pool. GPool() *gp.Pool // SPool returns the session pool. SPool() util.SessionPool // Close closes the goroutine pool. Close() }
Pool is used to reuse goroutine and session.
type TableInfoGetter ¶
type TableInfoGetter interface { // TableInfoByID returns the table info specified by the physicalID. // If the physicalID is corresponding to a partition, return its parent table. TableInfoByID(is infoschema.InfoSchema, physicalID int64) (table.Table, bool) }
TableInfoGetter is used to get table meta info.
func NewTableInfoGetter ¶
func NewTableInfoGetter() TableInfoGetter
NewTableInfoGetter creates a TableInfoGetter.