Fix SQL query for camelCase tables row estimation
This commit is contained in:
@@ -224,9 +224,7 @@ func (client *Client) TableRows(table string, opts RowsOptions) (*Result, error)
|
|||||||
|
|
||||||
func (client *Client) EstimatedTableRowsCount(table string, opts RowsOptions) (*Result, error) {
|
func (client *Client) EstimatedTableRowsCount(table string, opts RowsOptions) (*Result, error) {
|
||||||
schema, table := getSchemaAndTable(table)
|
schema, table := getSchemaAndTable(table)
|
||||||
sql := fmt.Sprintf(`SELECT reltuples FROM pg_class WHERE oid = '%s.%s'::regclass;`, schema, table)
|
result, err := client.query(statements.EstimatedTableRowCount, schema, table)
|
||||||
|
|
||||||
result, err := client.query(sql)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,17 @@ SELECT
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
EstimatedTableRowCount = `
|
||||||
|
SELECT
|
||||||
|
reltuples
|
||||||
|
FROM
|
||||||
|
pg_class
|
||||||
|
WHERE
|
||||||
|
oid = ('"' || $1::text || '"."' || $2::text || '"')::regclass
|
||||||
|
`
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
TableIndexes = `
|
TableIndexes = `
|
||||||
SELECT
|
SELECT
|
||||||
indexname, indexdef
|
indexname, indexdef
|
||||||
|
|||||||
Reference in New Issue
Block a user