usage

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

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DumpStatsDeltaRatio is the lower bound of `Modify Count / Table Count` for stats delta to be dumped.
	DumpStatsDeltaRatio = 1 / 10000.0
)

Functions

func CollectColumnsInExtendedStats

func CollectColumnsInExtendedStats(sctx sessionctx.Context, tableID int64) ([]int64, error)

CollectColumnsInExtendedStats returns IDs of the columns involved in extended stats.

func GetPredicateColumns

func GetPredicateColumns(sctx sessionctx.Context, tableID int64) ([]int64, error)

GetPredicateColumns returns IDs of predicate columns, which are the columns whose stats are used(needed) when generating query plans.

func LoadColumnStatsUsage

func LoadColumnStatsUsage(sctx sessionctx.Context, loc *time.Location) (map[model.TableItemID]utilstats.ColStatsTimeInfo, error)

LoadColumnStatsUsage loads column stats usage information from disk.

func NewStatsUsageImpl

func NewStatsUsageImpl(statsHandle utilstats.StatsHandle) utilstats.StatsUsage

NewStatsUsageImpl creates a utilstats.StatsUsage.

func UpdateTableDeltaMap

func UpdateTableDeltaMap(m map[int64]variable.TableDelta, id int64, delta int64, count int64, colSize *map[int64]int64)

UpdateTableDeltaMap updates the delta of the table.

Types

type GlobalIndexID

type GlobalIndexID struct {
	TableID int64
	IndexID int64
}

GlobalIndexID is the key type for indexUsageMap.

type IndexUsageInformation

type IndexUsageInformation struct {
	LastUsedAt   string
	QueryCount   int64
	RowsSelected int64
}

IndexUsageInformation is the data struct to store index usage information.

type SessionIndexUsageCollector

type SessionIndexUsageCollector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SessionIndexUsageCollector is a list item that holds the index usage mapper. If you want to write or read mapper, you must lock it. TODO: use a third-party thread-safe list implementation instead of maintaining the list manually. TODO: merge this list into SessionStatsList.

[session1]                [session2]                        [sessionN]
    |                         |                                 |
update into              update into                       update into
    |                         |                                 |
    v                         v                                 v

[StatsHandle.Head] --> [session1.IndexUsage] --> [session2.IndexUsage] --> ... --> [sessionN.IndexUsage]

|                         |                                 |
+-------------------------+---------------------------------+
                          |
        collect and dump into storage periodically
                          |
                          v
                      [storage]

func (*SessionIndexUsageCollector) Delete

func (s *SessionIndexUsageCollector) Delete()

Delete will set s.deleted to true which means it can be deleted from linked list.

func (*SessionIndexUsageCollector) Update

func (s *SessionIndexUsageCollector) Update(tableID int64, indexID int64, value *IndexUsageInformation)

Update updates the mapper in SessionIndexUsageCollector.

type SessionStatsItem

type SessionStatsItem struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SessionStatsItem is a list item that holds the delta mapper. If you want to write or read mapper, you must lock it.

func (*SessionStatsItem) ClearForTest

func (s *SessionStatsItem) ClearForTest()

ClearForTest clears the mapper for test.

func (*SessionStatsItem) Delete

func (s *SessionStatsItem) Delete()

Delete only sets the deleted flag true, it will be deleted from list when DumpStatsDeltaToKV is called.

func (*SessionStatsItem) Update

func (s *SessionStatsItem) Update(id int64, delta int64, count int64, colSize *map[int64]int64)

Update will updates the delta and count for one table id.

func (*SessionStatsItem) UpdateColStatsUsage

func (s *SessionStatsItem) UpdateColStatsUsage(colMap map[model.TableItemID]time.Time)

UpdateColStatsUsage updates the last time when the column stats are used(needed).

type SessionStatsList

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

SessionStatsList is a list of SessionStatsItem, which is used to collect stats usage and table delta information from sessions. TODO: merge SessionIndexUsage into this list.

[session1]                [session2]                        [sessionN]
    |                         |                                 |
update into              update into                       update into
    |                         |                                 |
    v                         v                                 v

[StatsList.Head] --> [session1.StatsItem] --> [session2.StatsItem] --> ... --> [sessionN.StatsItem]

|                         |                                 |
+-------------------------+---------------------------------+
                          |
        collect and dump into storage periodically
                          |
                          v
                      [storage]

func NewSessionStatsList

func NewSessionStatsList() *SessionStatsList

NewSessionStatsList initializes a new SessionStatsList.

func (*SessionStatsList) NewSessionStatsItem

func (sl *SessionStatsList) NewSessionStatsItem() *SessionStatsItem

NewSessionStatsItem allocates a stats collector for a session.

func (*SessionStatsList) ResetSessionStatsList

func (sl *SessionStatsList) ResetSessionStatsList()

ResetSessionStatsList resets this list.

func (*SessionStatsList) SessionStatsUsage

func (sl *SessionStatsList) SessionStatsUsage() *StatsUsage

SessionStatsUsage returns the current *StatsUsage.

func (*SessionStatsList) SessionTableDelta

func (sl *SessionStatsList) SessionTableDelta() *TableDelta

SessionTableDelta returns the current *TableDelta.

func (*SessionStatsList) SweepSessionStatsList

func (sl *SessionStatsList) SweepSessionStatsList()

SweepSessionStatsList will loop over the list, merge each session's local stats into handle and remove closed session's collector.

type StatsUsage

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

StatsUsage maps (tableID, columnID) to the last time when the column stats are used(needed). All methods of it are thread-safe.

func NewStatsUsage

func NewStatsUsage() *StatsUsage

NewStatsUsage creates a new StatsUsage.

func (*StatsUsage) GetUsageAndReset

func (m *StatsUsage) GetUsageAndReset() map[model.TableItemID]time.Time

GetUsageAndReset gets the usage and resets the StatsUsage.

func (*StatsUsage) Merge

func (m *StatsUsage) Merge(other map[model.TableItemID]time.Time)

Merge merges the usageMap into the StatsUsage.

func (*StatsUsage) Reset

func (m *StatsUsage) Reset()

Reset resets the StatsUsage.

type TableDelta

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

TableDelta is used to collect tables' change information. All methods of it are thread-safe.

func NewTableDelta

func NewTableDelta() *TableDelta

NewTableDelta creates a new TableDelta.

func (*TableDelta) GetDeltaAndReset

func (m *TableDelta) GetDeltaAndReset() map[int64]variable.TableDelta

GetDeltaAndReset gets the delta and resets the TableDelta.

func (*TableDelta) Merge

func (m *TableDelta) Merge(deltaMap map[int64]variable.TableDelta)

Merge merges the deltaMap into the TableDelta.

func (*TableDelta) Reset

func (m *TableDelta) Reset()

Reset resets the TableDelta.

func (*TableDelta) Update

func (m *TableDelta) Update(id int64, delta int64, count int64, colSize *map[int64]int64)

Update updates the delta of the table.

Jump to

Keyboard shortcuts

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