Documentation
¶
Overview ¶
Package explain provides SQL EXPLAIN plan analysis. It connects to a live database to run EXPLAIN on queries and detect performance issues like sequential scans and high-cost operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*PlanAnalyzer)
Option configures a PlanAnalyzer.
func WithAllowDML ¶
func WithAllowDML() Option
WithAllowDML permits EXPLAIN on INSERT/UPDATE/DELETE statements. It is OFF by default: only SELECT/WITH are explained, because feeding DML to a prod database — even under plain EXPLAIN — is a footgun (and EXPLAIN ANALYZE would execute it). When enabled, DML EXPLAINs still run inside a transaction that is always rolled back (see analyzePostgres/analyzeMySQL), so nothing is committed regardless.
type PlanAnalyzer ¶
type PlanAnalyzer struct {
// contains filtered or unexported fields
}
PlanAnalyzer runs EXPLAIN on queries against a live database.
func New ¶
New creates a PlanAnalyzer for the given database connection. dialect must be "postgres" or "mysql".