Documentation
¶
Overview ¶
Package estimator provides tools to estimate query timing for a production environment.
Package estimator provides tools to estimate query timing for a production environment.
Index ¶
- Constants
- type Config
- type Estimator
- type Event
- type Monitor
- type Profiler
- func (p *Profiler) CountSamples() int
- func (p *Profiler) EstimateTime(ctx context.Context) (string, error)
- func (p *Profiler) Finish() chan struct{}
- func (p *Profiler) IsEnoughSamples() bool
- func (p *Profiler) RenderStat() string
- func (p *Profiler) Start(ctx context.Context)
- func (p *Profiler) Stop()
- func (p *Profiler) TotalTime() float64
- func (p *Profiler) WaitEventsRatio() map[string]float64
- type ReadBlocksEvent
- type Result
- type ResultEvent
- type StatDatabase
- type Timing
- type TraceOptions
- type TraceStat
Constants ¶
const ( // ReadyEventType defines ready event type. ReadyEventType = "ready" // ResultEventType defines result event type. ResultEventType = "result" // ReadBlocksType defines client event that provides a number of reading blocks. ReadBlocksType = "read_blocks" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ReadRatio float64 `yaml:"readRatio"` WriteRatio float64 `yaml:"writeRatio"` ProfilingInterval time.Duration `yaml:"profilingInterval"` SampleThreshold int `yaml:"sampleThreshold"` }
Config describes options to estimate query timing.
type Estimator ¶
type Estimator struct {
// contains filtered or unexported fields
}
Estimator defines a timing estimator.
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor observes processes and system activity.
func NewMonitor ¶
NewMonitor creates a new monitor.
type Profiler ¶
type Profiler struct {
// contains filtered or unexported fields
}
Profiler defines a profiling structure.
func NewProfiler ¶
func NewProfiler(conn pgxtype.Querier, opts TraceOptions) *Profiler
NewProfiler creates a new profiler.
func (*Profiler) CountSamples ¶
CountSamples returns a number of samples.
func (*Profiler) EstimateTime ¶
EstimateTime estimates time.
func (*Profiler) Finish ¶
func (p *Profiler) Finish() chan struct{}
Finish returns a channel that's receiving data when profiling done.
func (*Profiler) IsEnoughSamples ¶
IsEnoughSamples checks if enough samples have been collected.
func (*Profiler) RenderStat ¶
RenderStat renders the collected profiler stats.
func (*Profiler) WaitEventsRatio ¶
WaitEventsRatio returns a ratio of wait events.
type ReadBlocksEvent ¶
ReadBlocksEvent defines a read blocks event.
type Result ¶
type Result struct { IsEnoughStat bool SampleCounter int TotalTime float64 EstTime string RenderedStat string WaitEventsRatio map[string]float64 }
Result represents results of estimation session.
type ResultEvent ¶
ResultEvent defines a result event.
type StatDatabase ¶
type StatDatabase struct { BlocksRead int64 `json:"blks_read"` BlocksHit int64 `json:"blks_hit"` BlockReadTime float64 `json:"blk_read_time"` BlockWriteTime float64 `json:"blk_write_time"` }
StatDatabase defines database blocks stats.
type Timing ¶
type Timing struct {
// contains filtered or unexported fields
}
Timing defines a timing estimator.
func (*Timing) CalcMax ¶
CalcMax calculates the maximum query time estimation for the production environment, given the prepared ratios.
func (*Timing) CalcMin ¶
CalcMin calculates the minimum query time estimation for the production environment, given the prepared ratios.
func (*Timing) SetRealReadRatio ¶
SetRealReadRatio sets real read ratio.