statistics

package
v0.0.0-...-ea486a4 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetStatisticsTableCache

func SetStatisticsTableCache(id int64, statsTbl *Table, version uint64)

SetStatisticsTableCache sets the statistics table cache.

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.
	ColOffsets    []int            // ColOffsets is the offset of columns in the table.
	IdxRecords    []ast.RecordSet  // IdxRecords is the record set of index columns.
	IdxOffsets    []int            // IdxOffsets is the offset of indices in the table.
	PkRecords     ast.RecordSet    // PkRecords is the record set of primary key of integer type.
	PkOffset      int              // PkOffset is the offset of primary key of integer type in the table.
}

Builder describes information needed by NewTable

func (*Builder) NewTable

func (b *Builder) NewTable() (*Table, error)

NewTable creates a table statistics.

type Column

type Column struct {
	ID  int64 // Column ID.
	NDV int64 // Number of distinct values.

	// Histogram elements.
	//
	// A bucket number is the number of items stored in all previous buckets and the current bucket.
	// bucket numbers are always in increasing order.
	//
	// A bucket value is the greatest item value stored in the bucket.
	//
	// Repeat is the number of repeats of the bucket value, it can be used to find popular values.
	//
	// TODO: We could have make a bucket struct contains number, value and repeats.
	Numbers []int64
	Values  []types.Datum
	Repeats []int64
}

Column represents statistics for a column.

func (*Column) BetweenRowCount

func (c *Column) 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 (*Column) EqualRowCount

func (c *Column) EqualRowCount(sc *variable.StatementContext, value types.Datum) (int64, error)

EqualRowCount estimates the row count where the column equals to value.

func (*Column) GreaterRowCount

func (c *Column) GreaterRowCount(sc *variable.StatementContext, value types.Datum) (int64, error)

GreaterRowCount estimates the row count where the column greater than value.

func (*Column) LessRowCount

func (c *Column) LessRowCount(sc *variable.StatementContext, value types.Datum) (int64, error)

LessRowCount estimates the row count where the column less than value.

func (*Column) String

func (c *Column) String() string

type FMSketch

type FMSketch struct {
	// contains filtered or unexported fields
}

FMSketch is used to count the number of distinct elements in a set.

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

Handle can update stats info periodically.

func NewHandle

func NewHandle(ctx context.Context) *Handle

NewHandle creates a Handle for update stats.

func (*Handle) Clear

func (h *Handle) Clear()

Clear the statsTblCache, only for test.

func (*Handle) Update

func (h *Handle) Update(is infoschema.InfoSchema) error

Update reads stats meta from store and updates the stats map.

type Table

type Table struct {
	Info    *model.TableInfo
	Columns []*Column
	Indices []*Column
	Count   int64 // Total row count in a table.
	Pseudo  bool
}

Table represents statistics for a table.

func GetStatisticsTableCache

func GetStatisticsTableCache(tblInfo *model.TableInfo) *Table

GetStatisticsTableCache retrieves the statistics table from cache, and the cache will be updated by a goroutine.

func PseudoTable

func PseudoTable(ti *model.TableInfo) *Table

PseudoTable creates a pseudo table statistics when statistic can not be found in KV store.

func TableStatsFromStorage

func TableStatsFromStorage(ctx context.Context, info *model.TableInfo, count int64) (*Table, error)

TableStatsFromStorage loads table stats info from storage.

func (*Table) SaveToStorage

func (t *Table) SaveToStorage(ctx context.Context) error

SaveToStorage saves stats table to storage.

func (*Table) String

func (t *Table) String() string

String implements Stringer interface.

Jump to

Keyboard shortcuts

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