Documentation
¶
Index ¶
- func ApplyPostProcessors(pgConf *pkg.PostgresConf, sysInfo *sysinfo.SystemInfo) error
- func GetDefaults() map[string]string
- func GetPgTuneManagedParams() []string
- func GetRecommendedMaxConnections(dbType string) int
- func OptimizeAndSave(opts OptimizeOptions) (string, error)
- func RegisterPostProcessor(processor PostProcessor)
- type AutoConfFile
- type AutoConfParameter
- type OptimizeOptions
- type PostProcessor
- type TunedParameters
- type TuningConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyPostProcessors ¶
func ApplyPostProcessors(pgConf *pkg.PostgresConf, sysInfo *sysinfo.SystemInfo) error
ApplyPostProcessors applies all registered post-processors to the configuration
func GetDefaults ¶ added in v1.0.4
func GetPgTuneManagedParams ¶
func GetPgTuneManagedParams() []string
GetPgTuneManagedParams returns the list of parameters managed by pg_tune
func GetRecommendedMaxConnections ¶
GetRecommendedMaxConnections returns recommended max_connections based on DB type
func OptimizeAndSave ¶
func OptimizeAndSave(opts OptimizeOptions) (string, error)
OptimizeAndSave calculates optimal PostgreSQL configuration and generates content for postgresql.tune.conf
func RegisterPostProcessor ¶
func RegisterPostProcessor(processor PostProcessor)
RegisterPostProcessor registers a new post-processor function
Types ¶
type AutoConfFile ¶
type AutoConfFile struct {
Parameters map[string]*AutoConfParameter
Comments []string // standalone comments (not associated with parameters)
}
AutoConfFile represents the parsed postgres.auto.conf file
func ParseAutoConf ¶
func ParseAutoConf(path string) (*AutoConfFile, error)
ParseAutoConf parses a postgres.auto.conf file
func (*AutoConfFile) MergeWithTunedParams ¶
func (ac *AutoConfFile) MergeWithTunedParams(params *TunedParameters)
MergeWithTunedParams merges tuned parameters into the auto.conf, updating only pg_tune managed params
func (*AutoConfFile) WriteToFile ¶
func (ac *AutoConfFile) WriteToFile(path string) error
WriteToFile writes the auto.conf to a file
type AutoConfParameter ¶
AutoConfParameter represents a single parameter in postgres.auto.conf
type OptimizeOptions ¶
type OptimizeOptions struct {
Enabled bool
DataDir string
DBType string
MaxConnections int
MemoryMB int
Cores int
SystemInfo *sysinfo.SystemInfo
}
OptimizeOptions contains options for optimizing PostgreSQL configuration
type PostProcessor ¶
type PostProcessor func(*pkg.PostgresConf, *sysinfo.SystemInfo) error
PostProcessor is a function type for processing PostgreSQL configuration
type TunedParameters ¶
type TunedParameters struct {
// Memory parameters (in KB unless noted)
EffectiveCacheSize Size `pretty:"format=bytes" json:"effective_cache_size,omitempty"` // effective_cache_size
MaintenanceWorkMem Size `pretty:"format=bytes" json:"maintenance_work_mem,omitempty"` // maintenance_work_mem
WorkMem Size `pretty:"format=bytes" json:"work_mem,omitempty"` // work_mem
// WAL parameters (in KB unless noted)
WalBuffers Size `pretty:"format=bytes" json:"wal_buffers,omitempty"` // wal_buffers
MinWalSize Size `pretty:"format=bytes" json:"min_wal_size,omitempty"` // min_wal_size
MaxWalSize Size `pretty:"format=bytes" json:"max_wal_size,omitempty"` // max_wal_size
CheckpointCompletionTarget float64 `json:"checkpoint_completion_target,omitempty"` // checkpoint_completion_target
// Performance parameters
RandomPageCost float64 `json:"random_page_cost,omitempty"` // random_page_cost
EffectiveIoConcurrency *int `json:"effective_io_concurrency,omitempty"` // effective_io_concurrency (nil if not applicable)
DefaultStatisticsTarget int `json:"default_statistics_target,omitempty"` // default_statistics_target
// Parallel processing parameters
MaxWorkerProcesses int `json:"max_worker_processes,omitempty"` // max_worker_processes
MaxParallelWorkers int `json:"max_parallel_workers,omitempty"` // max_parallel_workers (PG 10+)
MaxParallelWorkersPerGather int `json:"max_parallel_workers_per_gather,omitempty"` // max_parallel_workers_per_gather
MaxParallelMaintenanceWorkers *int `json:"max_parallel_maintenance_workers,omitempty"` // max_parallel_maintenance_workers (PG 11+)
// WAL level settings
WalLevel string `json:"wal_level,omitempty"` // wal_level
MaxWalSenders *int `json:"max_wal_senders,omitempty"` // max_wal_senders (set to 0 when wal_level=minimal)
// Connection parameters
MaxConnections int `json:"max_connections,omitempty"` // max_connections
// Huge pages setting
HugePages string `json:"huge_pages,omitempty"` // huge_pages
// Warning messages for memory constraints
Warnings []string `json:"warnings,omitempty"`
}
TunedParameters contains the calculated PostgreSQL parameters
func CalculateOptimalConfig ¶
func CalculateOptimalConfig(config *TuningConfig) (*TunedParameters, error)
CalculateOptimalConfig generates optimal PostgreSQL configuration based on system info
func (TunedParameters) AsConf ¶ added in v1.0.4
func (tp TunedParameters) AsConf() (*config.Conf, error)
func (TunedParameters) Pretty ¶ added in v1.0.4
func (tp TunedParameters) Pretty() api.Text
type TuningConfig ¶
type TuningConfig struct {
sysinfo.Resources
PostgreSQLVersion float64
// MaxConnections is the maximum number of database connections
MaxConnections int
// DBType is the database workload type
DBType string
OSType sysinfo.OSType
// DiskType overrides detected disk type if specified
DiskType *sysinfo.DiskType
}
TuningConfig contains the input parameters for PostgreSQL tuning