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, ")
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")));
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))
{
}
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")));
}