storage

package
v1.1.0-beta.0...-de36787 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlocksToJSONTable

func BlocksToJSONTable(blocks [][]byte) (*statsutil.JSONTable, error)

BlocksToJSONTable convert gzip-compressed blocks to JSONTable

func CMSketchAndTopNFromStorageWithHighPriority

func CMSketchAndTopNFromStorageWithHighPriority(sctx sessionctx.Context, tblID int64, isIndex, histID, statsVer int64) (_ *statistics.CMSketch, _ *statistics.TopN, err error)

CMSketchAndTopNFromStorageWithHighPriority reads CMSketch and TopN from storage.

func CMSketchFromStorage

func CMSketchFromStorage(sctx sessionctx.Context, tblID int64, isIndex int, histID int64) (_ *statistics.CMSketch, err error)

CMSketchFromStorage reads CMSketch from storage

func ChangeGlobalStatsID

func ChangeGlobalStatsID(
	ctx context.Context,
	sctx sessionctx.Context,
	from, to int64,
) error

ChangeGlobalStatsID changes the table ID in global-stats to the new table ID.

func CheckSkipColumnPartiion

func CheckSkipColumnPartiion(sctx sessionctx.Context, tblID int64, isIndex int, histsID int64) error

CheckSkipColumnPartiion checks if we can skip loading the partition.

func CheckSkipPartition

func CheckSkipPartition(sctx sessionctx.Context, tblID int64, isIndex int) error

CheckSkipPartition checks if we can skip loading the partition.

func CleanFakeItemsForShowHistInFlights

func CleanFakeItemsForShowHistInFlights(statsCache statstypes.StatsCache) int

CleanFakeItemsForShowHistInFlights cleans the invalid inserted items.

func ClearOutdatedHistoryStats

func ClearOutdatedHistoryStats(sctx sessionctx.Context) error

ClearOutdatedHistoryStats clear outdated historical stats

func DeleteTableStatsFromKV

func DeleteTableStatsFromKV(sctx sessionctx.Context, statsIDs []int64) (err error)

DeleteTableStatsFromKV deletes table statistics from kv. A statsID refers to statistic of a table or a partition.

func DumpTableStatColSizeToKV

func DumpTableStatColSizeToKV(sctx sessionctx.Context, id int64, delta variable.TableDelta) error

DumpTableStatColSizeToKV dumps the column size stats to storage.

func ExtendedStatsFromStorage

func ExtendedStatsFromStorage(sctx sessionctx.Context, table *statistics.Table, tableID int64, loadAll bool) (*statistics.Table, error)

ExtendedStatsFromStorage reads extended stats from storage.

func FMSketchFromStorage

func FMSketchFromStorage(sctx sessionctx.Context, tblID int64, isIndex, histID int64) (_ *statistics.FMSketch, err error)

FMSketchFromStorage reads FMSketch from storage

func GCStats

func GCStats(
	sctx sessionctx.Context,
	statsHandle types.StatsHandle,
	is infoschema.InfoSchema,
	ddlLease time.Duration,
) (err error)

GCStats will garbage collect the useless stats' info. For dropped tables, we will first update their version so that other tidb could know that table is deleted.

func GenJSONTableFromStats

func GenJSONTableFromStats(
	sctx sessionctx.Context,
	dbName string,
	tableInfo *model.TableInfo,
	tbl *statistics.Table,
	colStatsUsage map[model.TableItemID]statstypes.ColStatsTimeInfo,
) (*statsutil.JSONTable, error)

GenJSONTableFromStats generate jsonTable from tableInfo and stats

func HistMetaFromStorageWithHighPriority

func HistMetaFromStorageWithHighPriority(sctx sessionctx.Context, item *model.TableItemID, possibleColInfo *model.ColumnInfo) (*statistics.Histogram, *types.Datum, int64, int64, error)

HistMetaFromStorageWithHighPriority reads the meta info of the histogram from the storage.

func HistogramFromStorageWithPriority

func HistogramFromStorageWithPriority(
	sctx sessionctx.Context,
	tableID int64,
	colID int64,
	tp *types.FieldType,
	distinct int64,
	isIndex int,
	ver uint64,
	nullCount int64,
	totColSize int64,
	corr float64,
	priority int,
) (*statistics.Histogram, error)

HistogramFromStorageWithPriority wraps the HistogramFromStorage with the given kv.Priority. Sync load and async load will use high priority to get data.

func InsertColStats2KV

func InsertColStats2KV(
	ctx context.Context,
	sctx sessionctx.Context,
	physicalID int64,
	colInfos []*model.ColumnInfo,
) (uint64, error)

InsertColStats2KV insert a record to stats_histograms with distinct_count 1 and insert a bucket to stats_buckets with default value. This operation also updates version.

func InsertExtendedStats

func InsertExtendedStats(sctx sessionctx.Context,
	statsCache types.StatsCache,
	statsName string, colIDs []int64, tp int, tableID int64, ifNotExists bool) (statsVer uint64, err error)

InsertExtendedStats inserts a record into mysql.stats_extended and update version in mysql.stats_meta.

func InsertTableStats2KV

func InsertTableStats2KV(
	ctx context.Context,
	sctx sessionctx.Context,
	info *model.TableInfo,
	physicalID int64,
) (uint64, error)

InsertTableStats2KV inserts a record standing for a new table to stats_meta and inserts some records standing for the new columns and indices which belong to this table.

func JSONTableToBlocks

func JSONTableToBlocks(jsTable *statsutil.JSONTable, blockSize int) ([][]byte, error)

JSONTableToBlocks convert JSONTable to json, then compresses it to blocks by gzip.

func LoadHistogram

func LoadHistogram(sctx sessionctx.Context, tableID int64, isIndex int, histID int64, tableInfo *model.TableInfo) (*statistics.Histogram, error)

LoadHistogram will load histogram from storage.

func LoadNeededHistograms

func LoadNeededHistograms(sctx sessionctx.Context, is infoschema.InfoSchema, statsHandle statstypes.StatsHandle, loadFMSketch bool) (err error)

LoadNeededHistograms will load histograms for those needed columns/indices.

func MarkExtendedStatsDeleted

func MarkExtendedStatsDeleted(sctx sessionctx.Context,
	statsCache types.StatsCache,
	statsName string, tableID int64, ifExists bool) (statsVer uint64, err error)

MarkExtendedStatsDeleted update the status of mysql.stats_extended to be `deleted` and the version of mysql.stats_meta.

func NewStatsGC

func NewStatsGC(statsHandle types.StatsHandle) types.StatsGC

NewStatsGC creates a new StatsGC.

func NewStatsReadWriter

func NewStatsReadWriter(statsHandler statstypes.StatsHandle) statstypes.StatsReadWriter

NewStatsReadWriter creates a new StatsReadWriter.

func SaveExtendedStatsToStorage

func SaveExtendedStatsToStorage(sctx sessionctx.Context,
	tableID int64, extStats *statistics.ExtendedStatsColl, isLoad bool) (statsVer uint64, err error)

SaveExtendedStatsToStorage writes extended stats of a table into mysql.stats_extended.

func SaveMetaToStorage

func SaveMetaToStorage(
	sctx sessionctx.Context,
	tableID, count, modifyCount int64) (statsVer uint64, err error)

SaveMetaToStorage will save stats_meta to storage.

func SaveStatsToStorage

func SaveStatsToStorage(
	sctx sessionctx.Context,
	tableID int64,
	count, modifyCount int64,
	isIndex int,
	hg *statistics.Histogram,
	cms *statistics.CMSketch,
	topN *statistics.TopN,
	statsVersion int,
	isAnalyzed int64,
	updateAnalyzeTime bool,
) (statsVer uint64, err error)

SaveStatsToStorage saves the stats to storage. If count is negative, both count and modify count would not be used and not be written to the table. Unless, corresponding fields in the stats_meta table will be updated. TODO: refactor to reduce the number of parameters

func SaveTableStatsToStorage

func SaveTableStatsToStorage(sctx sessionctx.Context,
	results *statistics.AnalyzeResults, analyzeSnapshot bool) (statsVer uint64, err error)

SaveTableStatsToStorage saves the stats of a table to storage.

func StatsMetaByTableIDFromStorage

func StatsMetaByTableIDFromStorage(sctx sessionctx.Context, tableID int64, snapshot uint64) (version uint64, modifyCount, count int64, err error)

StatsMetaByTableIDFromStorage gets the stats meta of a table from storage.

func StatsMetaCountAndModifyCount

func StatsMetaCountAndModifyCount(
	ctx context.Context,
	sctx sessionctx.Context,
	tableID int64,
) (count, modifyCount int64, isNull bool, err error)

StatsMetaCountAndModifyCount reads count and modify_count for the given table from mysql.stats_meta.

func StatsMetaCountAndModifyCountForUpdate

func StatsMetaCountAndModifyCountForUpdate(
	ctx context.Context,
	sctx sessionctx.Context,
	tableID int64,
) (count, modifyCount int64, isNull bool, err error)

StatsMetaCountAndModifyCountForUpdate reads count and modify_count for the given table from mysql.stats_meta with lock.

func TableHistoricalStatsToJSON

func TableHistoricalStatsToJSON(sctx sessionctx.Context, physicalID int64, snapshot uint64) (jt *statsutil.JSONTable, exist bool, err error)

TableHistoricalStatsToJSON converts the historical stats of a table to JSONTable.

func TableStatsFromJSON

func TableStatsFromJSON(tableInfo *model.TableInfo, physicalID int64, jsonTbl *statsutil.JSONTable) (*statistics.Table, error)

TableStatsFromJSON loads statistic from JSONTable and return the Table of statistic.

func TableStatsFromStorage

func TableStatsFromStorage(sctx sessionctx.Context, snapshot uint64, tableInfo *model.TableInfo, tableID int64, loadAll bool, lease time.Duration, table *statistics.Table) (_ *statistics.Table, err error)

TableStatsFromStorage loads table stats info from storage.

func TopNFromStorage

func TopNFromStorage(sctx sessionctx.Context, tblID int64, isIndex int, histID int64) (_ *statistics.TopN, err error)

TopNFromStorage reads TopN from storage

func UpdateStatsMeta

func UpdateStatsMeta(
	ctx context.Context,
	sctx sessionctx.Context,
	startTS uint64,
	delta variable.TableDelta,
	id int64,
	isLocked bool,
) (err error)

UpdateStatsMeta update the stats meta stat for this Table.

func UpdateStatsMetaVersionForGC

func UpdateStatsMetaVersionForGC(
	ctx context.Context,
	sctx sessionctx.Context,
	physicalID int64,
) (uint64, error)

UpdateStatsMetaVersionForGC updates the version of stats_meta to be deleted soon.

func UpdateStatsVersion

func UpdateStatsVersion(ctx context.Context, sctx sessionctx.Context) error

UpdateStatsVersion will set statistics version to the newest TS, then tidb-server will reload automatic.

Types

type TestLoadStatsErr

type TestLoadStatsErr struct{}

TestLoadStatsErr is only for test.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL