querycost

package
v0.0.0-...-5ecede5 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: LGPL-3.0-or-later Imports: 8 Imported by: 2

Documentation

Overview

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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