Fix SQL query for camelCase tables row estimation
This commit is contained in:
parent
12717f15cc
commit
5af4332593
@ -224,9 +224,7 @@ func (client *Client) TableRows(table string, opts RowsOptions) (*Result, error)
|
||||
|
||||
func (client *Client) EstimatedTableRowsCount(table string, opts RowsOptions) (*Result, error) {
|
||||
schema, table := getSchemaAndTable(table)
|
||||
sql := fmt.Sprintf(`SELECT reltuples FROM pg_class WHERE oid = '%s.%s'::regclass;`, schema, table)
|
||||
|
||||
result, err := client.query(sql)
|
||||
result, err := client.query(statements.EstimatedTableRowCount, schema, table)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -33,7 +33,18 @@ SELECT
|
||||
inet_client_port(),
|
||||
inet_server_addr(),
|
||||
inet_server_port(),
|
||||
version()`
|
||||
version()`
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
EstimatedTableRowCount = `
|
||||
SELECT
|
||||
reltuples
|
||||
FROM
|
||||
pg_class
|
||||
WHERE
|
||||
oid = ('"' || $1::text || '"."' || $2::text || '"')::regclass
|
||||
`
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user