Documentation
¶
Index ¶
- Variables
- type Container
- func New(st *cluster.Settings, uniqueStmtFingerprintLimit *settings.IntSetting, ...) *Container
- func NewTempContainerFromExistingStmtStats(statistics []serverpb.StatementsResponse_CollectedStatementStatistics) (container *Container, ...)
- func NewTempContainerFromExistingTxnStats(...) (container *Container, ...)
- func (s *Container) Add(ctx context.Context, other *Container) (err error)
- func (s *Container) Clear(ctx context.Context)
- func (s *Container) Free(ctx context.Context)
- func (s *Container) IterateAggregatedTransactionStats(_ context.Context, _ *sqlstats.IteratorOptions, ...) error
- func (s *Container) IterateStatementStats(ctx context.Context, options *sqlstats.IteratorOptions, ...) error
- func (s *Container) IterateTransactionStats(ctx context.Context, options *sqlstats.IteratorOptions, ...) error
- func (s *Container) MergeApplicationStatementStats(ctx context.Context, other sqlstats.ApplicationStats, ...) (discardedStats uint64)
- func (s *Container) MergeApplicationTransactionStats(ctx context.Context, other sqlstats.ApplicationStats) (discardedStats uint64)
- func (s *Container) NewApplicationStatsWithInheritedOptions() sqlstats.ApplicationStats
- func (s *Container) RecordStatement(ctx context.Context, key roachpb.StatementStatisticsKey, ...) (roachpb.StmtFingerprintID, error)
- func (s *Container) RecordStatementExecStats(key roachpb.StatementStatisticsKey, stats execstats.QueryLevelStats) error
- func (s *Container) RecordTransaction(ctx context.Context, key roachpb.TransactionFingerprintID, ...) error
- func (s *Container) SaveToLog(ctx context.Context, appName string)
- func (s *Container) ShouldSaveLogicalPlanDesc(fingerprint string, implicitTxn bool, database string) bool
- func (s *Container) StmtStatsIterator(options *sqlstats.IteratorOptions) *StmtStatsIterator
- func (s *Container) TxnStatsIterator(options *sqlstats.IteratorOptions) *TxnStatsIterator
- type StmtStatsIterator
- type TxnStatsIterator
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMemoryPressure is returned from the Container when we have reached // the memory limit allowed. ErrMemoryPressure = errors.New("insufficient sql stats memory") // ErrFingerprintLimitReached is returned from the Container when we have // more fingerprints than the limit specified in the cluster setting. ErrFingerprintLimitReached = errors.New("sql stats fingerprint limit reached") // ErrExecStatsFingerprintFlushed is returned from the Container when the // stats object for the fingerprint has been flushed to system table before // the roachpb.ExecStats can be recorded. ErrExecStatsFingerprintFlushed = errors.New("stmtStats flushed before execution stats can be recorded") )
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container holds per-application statement and transaction statistics.
func New ¶
func New( st *cluster.Settings, uniqueStmtFingerprintLimit *settings.IntSetting, uniqueTxnFingerprintLimit *settings.IntSetting, uniqueStmtFingerprintCount *int64, uniqueTxnFingerprintCount *int64, mon *mon.BytesMonitor, appName string, knobs *sqlstats.TestingKnobs, ) *Container
New returns a new instance of Container.
func NewTempContainerFromExistingStmtStats ¶
func NewTempContainerFromExistingStmtStats( statistics []serverpb.StatementsResponse_CollectedStatementStatistics, ) ( container *Container, remaining []serverpb.StatementsResponse_CollectedStatementStatistics, err error, )
NewTempContainerFromExistingStmtStats creates a new Container by ingesting a slice of serverpb.StatementsResponse_CollectedStatementStatistics sorted by Key.KeyData.App field. It consumes the first chunk of the slice where all entries in the chunk contains the identical appName. The remaining slice is returned as the result. It returns a nil slice once all entries in statistics are consumed.
func NewTempContainerFromExistingTxnStats ¶
func NewTempContainerFromExistingTxnStats( statistics []serverpb.StatementsResponse_ExtendedCollectedTransactionStatistics, ) ( container *Container, remaining []serverpb.StatementsResponse_ExtendedCollectedTransactionStatistics, err error, )
NewTempContainerFromExistingTxnStats creates a new Container by ingesting a slice of CollectedTransactionStatistics sorted by .StatsData.App field. It consumes the first chunk of the slice where all entries in the chunk contains the identical appName. The remaining slice is returned as the result. It returns a nil slice once all entries in statistics are consumed.
func (*Container) Add ¶
Add combines one Container into another. Add manages locks on a, so taking a lock on a will cause a deadlock.
func (*Container) Clear ¶
Clear clears the data stored in this Container and prepare the Container for reuse.
func (*Container) Free ¶
Free frees the accounted resources from the Container. The Container is presumed to be no longer in use and its actual allocated memory will eventually be GC'd.
func (*Container) IterateAggregatedTransactionStats ¶
func (s *Container) IterateAggregatedTransactionStats( _ context.Context, _ *sqlstats.IteratorOptions, visitor sqlstats.AggregatedTransactionVisitor, ) error
IterateAggregatedTransactionStats implements sqlstats.ApplicationStats interface.
func (*Container) IterateStatementStats ¶
func (s *Container) IterateStatementStats( ctx context.Context, options *sqlstats.IteratorOptions, visitor sqlstats.StatementVisitor, ) error
IterateStatementStats implements sqlstats.Provider interface.
func (*Container) IterateTransactionStats ¶
func (s *Container) IterateTransactionStats( ctx context.Context, options *sqlstats.IteratorOptions, visitor sqlstats.TransactionVisitor, ) error
IterateTransactionStats implements sqlstats.Provider interface.
func (*Container) MergeApplicationStatementStats ¶
func (s *Container) MergeApplicationStatementStats( ctx context.Context, other sqlstats.ApplicationStats, transformer func(*roachpb.CollectedStatementStatistics), ) (discardedStats uint64)
MergeApplicationStatementStats implements the sqlstats.ApplicationStats interface.
func (*Container) MergeApplicationTransactionStats ¶
func (s *Container) MergeApplicationTransactionStats( ctx context.Context, other sqlstats.ApplicationStats, ) (discardedStats uint64)
MergeApplicationTransactionStats implements the sqlstats.ApplicationStats interface.
func (*Container) NewApplicationStatsWithInheritedOptions ¶
func (s *Container) NewApplicationStatsWithInheritedOptions() sqlstats.ApplicationStats
NewApplicationStatsWithInheritedOptions implements the sqlstats.ApplicationStats interface.
func (*Container) RecordStatement ¶
func (s *Container) RecordStatement( ctx context.Context, key roachpb.StatementStatisticsKey, value sqlstats.RecordedStmtStats, ) (roachpb.StmtFingerprintID, error)
RecordStatement implements sqlstats.Writer interface. RecordStatement saves per-statement statistics.
samplePlanDescription can be nil, as these are only sampled periodically per unique fingerprint. RecordStatement always returns a valid stmtFingerprintID corresponding to the given stmt regardless of whether the statement is actually recorded or not.
If the statement is not actually recorded due to either: 1. the memory budget has been exceeded 2. the unique statement fingerprint limit has been exceeded and error is being returned. Note: This error is only related to the operation of recording the statement statistics into in-memory structs. It is unrelated to the stmtErr in the arguments.
func (*Container) RecordStatementExecStats ¶
func (s *Container) RecordStatementExecStats( key roachpb.StatementStatisticsKey, stats execstats.QueryLevelStats, ) error
RecordStatementExecStats implements sqlstats.Writer interface.
func (*Container) RecordTransaction ¶
func (s *Container) RecordTransaction( ctx context.Context, key roachpb.TransactionFingerprintID, value sqlstats.RecordedTxnStats, ) error
RecordTransaction implements sqlstats.Writer interface and saves per-transaction statistics.
func (*Container) ShouldSaveLogicalPlanDesc ¶
func (s *Container) ShouldSaveLogicalPlanDesc( fingerprint string, implicitTxn bool, database string, ) bool
ShouldSaveLogicalPlanDesc implements sqlstats.Writer interface.
func (*Container) StmtStatsIterator ¶
func (s *Container) StmtStatsIterator(options *sqlstats.IteratorOptions) *StmtStatsIterator
StmtStatsIterator returns an instance of StmtStatsIterator.
func (*Container) TxnStatsIterator ¶
func (s *Container) TxnStatsIterator(options *sqlstats.IteratorOptions) *TxnStatsIterator
TxnStatsIterator returns an instance of TxnStatsIterator.
type StmtStatsIterator ¶
type StmtStatsIterator struct {
// contains filtered or unexported fields
}
StmtStatsIterator is an iterator that iterates over the statement statistics inside of a ssmemstorage.Container.
func NewStmtStatsIterator ¶
func NewStmtStatsIterator( container *Container, options *sqlstats.IteratorOptions, ) *StmtStatsIterator
NewStmtStatsIterator returns a StmtStatsIterator.
func (*StmtStatsIterator) Cur ¶
func (s *StmtStatsIterator) Cur() *roachpb.CollectedStatementStatistics
Cur returns the roachpb.CollectedStatementStatistics at the current internal counter.
func (*StmtStatsIterator) Next ¶
func (s *StmtStatsIterator) Next() bool
Next updates the current value returned by the subsequent Cur() call. Next() returns true if the following Cur() call is valid, false otherwise.
type TxnStatsIterator ¶
type TxnStatsIterator struct {
// contains filtered or unexported fields
}
TxnStatsIterator is an iterator that iterates over the transaction statistics inside a ssmemstorage.Container.
func NewTxnStatsIterator ¶
func NewTxnStatsIterator( container *Container, options *sqlstats.IteratorOptions, ) *TxnStatsIterator
NewTxnStatsIterator returns a new instance of TxnStatsIterator.
func (*TxnStatsIterator) Cur ¶
func (t *TxnStatsIterator) Cur() *roachpb.CollectedTransactionStatistics
Cur returns the roachpb.CollectedTransactionStatistics at the current internal counter.
func (*TxnStatsIterator) Next ¶
func (t *TxnStatsIterator) Next() bool
Next updates the current value returned by the subsequent Cur() call. Next() returns true if the following Cur() call is valid, false otherwise.