Index: gpPartition.cpp =================================================================== --- gpPartition.cpp (revision 7806) +++ gpPartition.cpp (working copy) @@ -96,6 +96,16 @@ wxString query; gpPartition *table=0; + // Greenplum returns reltuples and relpages as tuples per segmentDB and pages per segmentDB, + // so we need to multiply them by the number of segmentDBs to get reasonable values. + long gp_segments =1; + + query = wxT("SELECT count(*) AS gp_segments from pg_catalog.gp_configuration where definedprimary = 't' and content >= 0"); + gp_segments = StrToLong(collection->GetDatabase()->ExecuteScalar(query)); + if (gp_segments <= 1) + gp_segments = 1; + + pgSet *tables; query= wxT("SELECT rel.oid, relname, rel.reltablespace AS spcoid, spcname, pg_get_userbyid(relowner) AS relowner, relacl, relhasoids, ") @@ -152,7 +162,7 @@ table->iSetComment(tables->GetVal(wxT("description"))); table->iSetHasOids(tables->GetBool(wxT("relhasoids"))); - table->iSetEstimatedRows(tables->GetDouble(wxT("reltuples"))); + table->iSetEstimatedRows(tables->GetDouble(wxT("reltuples")) * gp_segments); table->iSetFillFactor(tables->GetVal(wxT("fillfactor"))); Index: pgTable.cpp =================================================================== --- pgTable.cpp (revision 7806) +++ pgTable.cpp (working copy) @@ -1194,6 +1194,17 @@ wxString query; pgTable *table=0; + // Greenplum returns reltuples and relpages as tuples per segmentDB and pages per segmentDB, + // so we need to multiply them by the number of segmentDBs to get reasonable values. + long gp_segments =1; + if (collection->GetConnection()->GetIsGreenplum()) + { + query = wxT("SELECT count(*) AS gp_segments from pg_catalog.gp_configuration where definedprimary = 't' and content >= 0"); + gp_segments = StrToLong(collection->GetDatabase()->ExecuteScalar(query)); + if (gp_segments <= 1) + gp_segments = 1; + } + pgSet *tables; if (collection->GetConnection()->BackendMinimumVersion(8, 0)) { @@ -1291,7 +1302,7 @@ } table->iSetComment(tables->GetVal(wxT("description"))); table->iSetHasOids(tables->GetBool(wxT("relhasoids"))); - table->iSetEstimatedRows(tables->GetDouble(wxT("reltuples"))); + table->iSetEstimatedRows(tables->GetDouble(wxT("reltuples")) * gp_segments); if (collection->GetConnection()->BackendMinimumVersion(8, 2)) { table->iSetFillFactor(tables->GetVal(wxT("fillfactor"))); }