Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
Collector represents a data structure to record the index usage for the whole node
func (*Collector) GCIndexUsage ¶
GCIndexUsage will delete the usage information of non-existent indexes. `tableMetaLookup` argument is represented as a function (but not `sessionctx.Context` or `infoschema.InfoSchema`) to avoid depending on `sessionctx.Context`.
func (*Collector) GetIndexUsage ¶
GetIndexUsage returns the index usage information
func (*Collector) SpawnSessionCollector ¶
func (c *Collector) SpawnSessionCollector() *SessionIndexUsageCollector
SpawnSessionCollector creates a new session collector attached to this global collector
func (*Collector) StartWorker ¶
func (c *Collector) StartWorker()
StartWorker starts the background worker inside
type GlobalIndexID ¶
GlobalIndexID is the key type for indexUsageMap.
type Sample ¶
type Sample struct { // LastUsedAt records the last time the index is used. LastUsedAt time.Time // QueryTotal records the total counts of queries which used this index. QueryTotal uint64 // KvReqTotal records the count of KV requests which are sent to read this index. KvReqTotal uint64 // RowAccessTotal sums the number of the rows scanned using this index. RowAccessTotal uint64 // PercentageAccess is a histogram where each bucket represents the number of accesses to the index where the // percentage of scanned rows to the total number of rows in the table falls within the ranges of // 0, 0-1, 1-10, 10-20, 20-50, 50-100, and 100. PercentageAccess [7]uint64 }
Sample is the data structure to store index usage information.
type SessionIndexUsageCollector ¶
type SessionIndexUsageCollector struct {
// contains filtered or unexported fields
}
SessionIndexUsageCollector collects index usage per-session
func (*SessionIndexUsageCollector) Flush ¶
func (s *SessionIndexUsageCollector) Flush()
Flush reports the indexUsage in `SessionIndexUsageCollector` to the global collector. It'll block until the data is received
func (*SessionIndexUsageCollector) Report ¶
func (s *SessionIndexUsageCollector) Report()
Report reports the indexUsage in `SessionIndexUsageCollector` to the global collector
type StmtIndexUsageCollector ¶
StmtIndexUsageCollector removes the duplicates index for recording `QueryTotal` in session collector
func NewStmtIndexUsageCollector ¶
func NewStmtIndexUsageCollector(sessionCollector *SessionIndexUsageCollector) *StmtIndexUsageCollector
NewStmtIndexUsageCollector creates a new StmtIndexUsageCollector.
func (*StmtIndexUsageCollector) Reset ¶
func (s *StmtIndexUsageCollector) Reset()
Reset resets the recorded index in the collector to avoid re-allocating for each statement.
func (*StmtIndexUsageCollector) Update ¶
func (s *StmtIndexUsageCollector) Update(tableID int64, indexID int64, sample Sample)
Update updates the index usage in the internal session collector. The `sample.QueryTotal` will be modified according to whether this index has been recorded in this statement usage collector.