explain

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps a database connection for running EXPLAIN queries.

func NewClient

func NewClient(db *sql.DB, driver Driver) *Client

NewClient creates a new Client from an existing *sql.DB.

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying database connection.

func (*Client) Run

func (c *Client) Run(ctx context.Context, mode Mode, query string, args []string) (*Result, error)

Run executes EXPLAIN or EXPLAIN ANALYZE for the given query with optional args.

type Driver added in v0.0.3

type Driver int

Driver identifies the database driver for EXPLAIN syntax differences.

const (
	Postgres Driver = iota
	MySQL
	TiDB
)

type Mode

type Mode int

Mode selects between EXPLAIN and EXPLAIN ANALYZE.

const (
	Explain Mode = iota // EXPLAIN (plan only)
	Analyze             // EXPLAIN ANALYZE (plan + actual execution)
)

func (Mode) String

func (m Mode) String() string

type Result

type Result struct {
	Plan     string
	Duration time.Duration
}

Result holds the output of an EXPLAIN query.

Jump to

Keyboard shortcuts

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