Documentation ¶
Index ¶
- type Builder
- type Column
- type FMSketch
- type Handle
- func (h *Handle) Clear()
- func (h *Handle) GetTableStats(tblInfo *model.TableInfo) *Table
- func (h *Handle) SaveToStorage(ctx context.Context, t *Table) error
- func (h *Handle) TableStatsFromStorage(ctx context.Context, info *model.TableInfo, count int64) (*Table, error)
- func (h *Handle) Update(is infoschema.InfoSchema) error
- func (h *Handle) UpdateTableStats(tables []*Table)
- type Histogram
- func (hg *Histogram) BetweenRowCount(sc *variable.StatementContext, a, b types.Datum) (int64, error)
- func (hg *Histogram) EqualRowCount(sc *variable.StatementContext, value types.Datum) (int64, error)
- func (hg *Histogram) GreaterRowCount(sc *variable.StatementContext, value types.Datum) (int64, error)
- func (hg *Histogram) LessRowCount(sc *variable.StatementContext, value types.Datum) (int64, error)
- type Index
- type Table
- func (t *Table) ColumnBetweenRowCount(sc *variable.StatementContext, a, b types.Datum, colInfo *model.ColumnInfo) (int64, error)
- func (t *Table) ColumnEqualRowCount(sc *variable.StatementContext, value types.Datum, colInfo *model.ColumnInfo) (int64, error)
- func (t *Table) ColumnGreaterRowCount(sc *variable.StatementContext, value types.Datum, colInfo *model.ColumnInfo) (int64, error)
- func (t *Table) ColumnIsInvalid(colInfo *model.ColumnInfo) bool
- func (t *Table) ColumnLessRowCount(sc *variable.StatementContext, value types.Datum, colInfo *model.ColumnInfo) (int64, error)
- func (t *Table) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct { Ctx context.Context // Ctx is the context. TblInfo *model.TableInfo // TblInfo is the table info of the table. StartTS int64 // StartTS is the start timestamp of the statistics table builder. Count int64 // Count is the total rows in the table. NumBuckets int64 // NumBuckets is the number of buckets a column histogram has. ColumnSamples [][]types.Datum // ColumnSamples is the sample of columns. ColIDs []int64 // ColIDs is the id of columns in the table. ColNDVs []int64 // ColNDVs is the NDV of columns. IdxRecords []ast.RecordSet // IdxRecords is the record set of index columns. IdxIDs []int64 // IdxIDs is the id of indices in the table. PkRecords ast.RecordSet // PkRecords is the record set of primary key of integer type. PkID int64 // PkID is the id of primary key with integer type in the table. // contains filtered or unexported fields }
Builder describes information needed by NewTable
type FMSketch ¶
type FMSketch struct {
// contains filtered or unexported fields
}
FMSketch is used to count the number of distinct elements in a set.
func (*FMSketch) InsertValue ¶
InsertValue inserts a value into the FM sketch.
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle can update stats info periodically.
func (*Handle) GetTableStats ¶
GetTableStats retrieves the statistics table from cache, and the cache will be updated by a goroutine.
func (*Handle) SaveToStorage ¶
SaveToStorage saves stats table to storage.
func (*Handle) TableStatsFromStorage ¶
func (h *Handle) TableStatsFromStorage(ctx context.Context, info *model.TableInfo, count int64) (*Table, error)
TableStatsFromStorage loads table stats info from storage.
func (*Handle) Update ¶
func (h *Handle) Update(is infoschema.InfoSchema) error
Update reads stats meta from store and updates the stats map.
func (*Handle) UpdateTableStats ¶
UpdateTableStats updates the statistics table cache using copy on write.
type Histogram ¶
type Histogram struct { ID int64 // Column ID. NDV int64 // Number of distinct values. Buckets []bucket }
Histogram represents statistics for a column or index.
func (*Histogram) BetweenRowCount ¶
func (hg *Histogram) BetweenRowCount(sc *variable.StatementContext, a, b types.Datum) (int64, error)
BetweenRowCount estimates the row count where column greater or equal to a and less than b.
func (*Histogram) EqualRowCount ¶
EqualRowCount estimates the row count where the column equals to value.
func (*Histogram) GreaterRowCount ¶
func (hg *Histogram) GreaterRowCount(sc *variable.StatementContext, value types.Datum) (int64, error)
GreaterRowCount estimates the row count where the column greater than value.
func (*Histogram) LessRowCount ¶
LessRowCount estimates the row count where the column less than value.
type Table ¶
type Table struct { Info *model.TableInfo Columns map[int64]*Column Indices map[int64]*Index Count int64 // Total row count in a table. Pseudo bool }
Table represents statistics for a table.
func PseudoTable ¶
PseudoTable creates a pseudo table statistics when statistic can not be found in KV store.
func (*Table) ColumnBetweenRowCount ¶
func (t *Table) ColumnBetweenRowCount(sc *variable.StatementContext, a, b types.Datum, colInfo *model.ColumnInfo) (int64, error)
ColumnBetweenRowCount estimates the row count where column greater or equal to a and less than b.
func (*Table) ColumnEqualRowCount ¶
func (t *Table) ColumnEqualRowCount(sc *variable.StatementContext, value types.Datum, colInfo *model.ColumnInfo) (int64, error)
ColumnEqualRowCount estimates the row count where the column equals to value.
func (*Table) ColumnGreaterRowCount ¶
func (t *Table) ColumnGreaterRowCount(sc *variable.StatementContext, value types.Datum, colInfo *model.ColumnInfo) (int64, error)
ColumnGreaterRowCount estimates the row count where the column greater than value.
func (*Table) ColumnIsInvalid ¶
func (t *Table) ColumnIsInvalid(colInfo *model.ColumnInfo) bool
ColumnIsInvalid checks if this column is invalid. Exported for test.
func (*Table) ColumnLessRowCount ¶
func (t *Table) ColumnLessRowCount(sc *variable.StatementContext, value types.Datum, colInfo *model.ColumnInfo) (int64, error)
ColumnLessRowCount estimates the row count where the column less than value.