querycost

package
v0.0.0-...-14a8109 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Select = "select"
	Insert = "insert"
	Update = "update"
	Delete = "delete"

	Set  = "set"
	From = "from"
	Into = "into"

	Quote  = `"`
	Lparen = "("
)
View Source
const (
	SelectCost = 1
	UpdateCost = 1
	InsertCost = 1
	DeleteCost = 1

	SelectRowCoeff = 0.0001
	InsertRowCoeff = 0.0001
	DeleteRowCoeff = 0.0001
	UpdateRowCoeff = 0.0001
)

Variables

View Source
var DeleteMinimumThreeFieldsError = errors.New("DELETE query must consist minimum of 3 fields")
View Source
var FromStatementMissingError = errors.New("FROM statement missing")
View Source
var IntoStatementMissingError = errors.New("INTO statement missing")
View Source
var SetStatementMissingError = errors.New("SET statement missing")
View Source
var UnknownQueryTypeError = errors.New("Unknown query type")

Functions

This section is empty.

Types

type DBCountQueryRowCounter

type DBCountQueryRowCounter struct {
}

func (*DBCountQueryRowCounter) RowCount

func (d *DBCountQueryRowCounter) RowCount(transaction *model.DbTransaction, tableName string) (int64, error)

type DeleteQueryType

type DeleteQueryType string

func (DeleteQueryType) CalculateCost

func (s DeleteQueryType) CalculateCost(rowCount int64) int64

func (DeleteQueryType) GetTableName

func (s DeleteQueryType) GetTableName() (string, error)

type ExplainAnalyzeQueryCoster

type ExplainAnalyzeQueryCoster struct {
}

func (*ExplainAnalyzeQueryCoster) QueryCost

func (*ExplainAnalyzeQueryCoster) QueryCost(transaction *model.DbTransaction, query string, args ...interface{}) (int64, error)

type ExplainQueryCoster

type ExplainQueryCoster struct {
}

func (*ExplainQueryCoster) QueryCost

func (*ExplainQueryCoster) QueryCost(transaction *model.DbTransaction, query string, args ...interface{}) (int64, error)

type FormulaQueryCoster

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

func (*FormulaQueryCoster) QueryCost

func (f *FormulaQueryCoster) QueryCost(transaction *model.DbTransaction, query string, args ...interface{}) (int64, error)

type InsertQueryType

type InsertQueryType string

func (InsertQueryType) CalculateCost

func (s InsertQueryType) CalculateCost(rowCount int64) int64

func (InsertQueryType) GetTableName

func (s InsertQueryType) GetTableName() (string, error)

type QueryCoster

type QueryCoster interface {
	QueryCost(*model.DbTransaction, string, ...interface{}) (int64, error)
}

func GetQueryCoster

func GetQueryCoster(tp QueryCosterType) QueryCoster

type QueryCosterType

type QueryCosterType int
const (
	ExplainQueryCosterType        QueryCosterType = iota
	ExplainAnalyzeQueryCosterType QueryCosterType = iota
	FormulaQueryCosterType        QueryCosterType = iota
)

type QueryType

type QueryType interface {
	GetTableName() (string, error)
	CalculateCost(int64) int64
}

type SelectQueryType

type SelectQueryType string

func (SelectQueryType) CalculateCost

func (s SelectQueryType) CalculateCost(rowCount int64) int64

func (SelectQueryType) GetTableName

func (s SelectQueryType) GetTableName() (string, error)

type TableRowCounter

type TableRowCounter interface {
	RowCount(*model.DbTransaction, string) (int64, error)
}

type UpdateQueryType

type UpdateQueryType string

func (UpdateQueryType) CalculateCost

func (s UpdateQueryType) CalculateCost(rowCount int64) int64

func (UpdateQueryType) GetTableName

func (s UpdateQueryType) GetTableName() (string, error)

Jump to

Keyboard shortcuts

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