Skip to content
Permalink
Browse files

[postgres] Fix estimated metadata queries fail for huge tables

Fixes #21517
  • Loading branch information
nyalldawson committed Mar 8, 2019
1 parent 97ba60e commit feb0c8bd6d7122de13a3cc6d4e2b4c7a5069d7eb
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/providers/postgres/qgspostgresprovider.cpp
@@ -3190,7 +3190,7 @@ long QgsPostgresProvider::featureCount() const
// - but make huge dataset usable.
if ( !mIsQuery && mUseEstimatedMetadata )
{
sql = QStringLiteral( "SELECT reltuples::int FROM pg_catalog.pg_class WHERE oid=regclass(%1)::oid" ).arg( quotedValue( mQuery ) );
sql = QStringLiteral( "SELECT reltuples::bigint FROM pg_catalog.pg_class WHERE oid=regclass(%1)::oid" ).arg( quotedValue( mQuery ) );
}
else
{
@@ -3249,7 +3249,7 @@ QgsRectangle QgsPostgresProvider::extent() const
{
if ( result.PQgetvalue( 0, 0 ).toInt() > 0 )
{
sql = QStringLiteral( "SELECT reltuples::int FROM pg_catalog.pg_class WHERE oid=regclass(%1)::oid" ).arg( quotedValue( mQuery ) );
sql = QStringLiteral( "SELECT reltuples::bigint FROM pg_catalog.pg_class WHERE oid=regclass(%1)::oid" ).arg( quotedValue( mQuery ) );
result = connectionRO()->PQexec( sql );
if ( result.PQresultStatus() == PGRES_TUPLES_OK
&& result.PQntuples() == 1

0 comments on commit feb0c8b

Please sign in to comment.
You can’t perform that action at this time.