mirror of https://github.com/citusdata/citus.git
Use RelationGetStatExtList instead of scanning pg_stats_ext
parent
4b03195c06
commit
4e1201a333
|
@ -490,23 +490,19 @@ GetExplicitStatisticsSchemaIdList(Oid relationId)
|
||||||
{
|
{
|
||||||
List *schemaIdList = NIL;
|
List *schemaIdList = NIL;
|
||||||
|
|
||||||
Relation pgStatistics = table_open(StatisticExtRelationId, AccessShareLock);
|
Relation relation = RelationIdGetRelation(relationId);
|
||||||
|
List *statsIdList = RelationGetStatExtList(relation);
|
||||||
|
RelationClose(relation);
|
||||||
|
|
||||||
int scanKeyCount = 1;
|
Oid statsId = InvalidOid;
|
||||||
ScanKeyData scanKey[1];
|
foreach_oid(statsId, statsIdList)
|
||||||
|
|
||||||
ScanKeyInit(&scanKey[0], Anum_pg_statistic_ext_stxrelid,
|
|
||||||
BTEqualStrategyNumber, F_OIDEQ, relationId);
|
|
||||||
|
|
||||||
bool useIndex = true;
|
|
||||||
SysScanDesc scanDescriptor = systable_beginscan(pgStatistics,
|
|
||||||
StatisticExtRelidIndexId,
|
|
||||||
useIndex, NULL, scanKeyCount,
|
|
||||||
scanKey);
|
|
||||||
|
|
||||||
HeapTuple heapTuple = systable_getnext(scanDescriptor);
|
|
||||||
while (HeapTupleIsValid(heapTuple))
|
|
||||||
{
|
{
|
||||||
|
HeapTuple heapTuple = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statsId));
|
||||||
|
if (!HeapTupleIsValid(heapTuple))
|
||||||
|
{
|
||||||
|
ereport(ERROR, (errmsg("cache lookup failed for statistics "
|
||||||
|
"object with oid %u", statsId)));
|
||||||
|
}
|
||||||
FormData_pg_statistic_ext *statisticsForm =
|
FormData_pg_statistic_ext *statisticsForm =
|
||||||
(FormData_pg_statistic_ext *) GETSTRUCT(heapTuple);
|
(FormData_pg_statistic_ext *) GETSTRUCT(heapTuple);
|
||||||
|
|
||||||
|
@ -515,12 +511,9 @@ GetExplicitStatisticsSchemaIdList(Oid relationId)
|
||||||
{
|
{
|
||||||
schemaIdList = lappend_oid(schemaIdList, schemaId);
|
schemaIdList = lappend_oid(schemaIdList, schemaId);
|
||||||
}
|
}
|
||||||
|
ReleaseSysCache(heapTuple);
|
||||||
heapTuple = systable_getnext(scanDescriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
systable_endscan(scanDescriptor);
|
|
||||||
table_close(pgStatistics, NoLock);
|
|
||||||
|
|
||||||
return schemaIdList;
|
return schemaIdList;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue