PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ pg_get_nd_stats()

static ND_STATS* pg_get_nd_stats ( const Oid  table_oid,
AttrNumber  att_num,
int  mode,
bool  only_parent 
)
static

Pull the stats object from the PgSQL system catalogs.

Used by the selectivity functions and the debugging functions.

Definition at line 949 of file gserialized_estimate.c.

950 {
951  HeapTuple stats_tuple = NULL;
952  ND_STATS *nd_stats;
953 
954  /* First pull the stats tuple for the whole tree */
955  if ( ! only_parent )
956  {
957  POSTGIS_DEBUGF(2, "searching whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
958  stats_tuple = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(table_oid), Int16GetDatum(att_num), BoolGetDatum(true));
959  if ( stats_tuple )
960  POSTGIS_DEBUGF(2, "found whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
961  }
962  /* Fall-back to main table stats only, if not found for whole tree or explicitly ignored */
963  if ( only_parent || ! stats_tuple )
964  {
965  POSTGIS_DEBUGF(2, "searching parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
966  stats_tuple = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(table_oid), Int16GetDatum(att_num), BoolGetDatum(false));
967  if ( stats_tuple )
968  POSTGIS_DEBUGF(2, "found parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
969  }
970  if ( ! stats_tuple )
971  {
972  POSTGIS_DEBUGF(2, "stats for \"%s\" do not exist", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
973  return NULL;
974  }
975 
976  nd_stats = pg_nd_stats_from_tuple(stats_tuple, mode);
977  ReleaseSysCache(stats_tuple);
978  if ( ! nd_stats )
979  {
980  POSTGIS_DEBUGF(2,
981  "histogram for attribute %d of table \"%s\" does not exist?",
982  att_num, get_rel_name(table_oid));
983  }
984 
985  return nd_stats;
986 }
static ND_STATS * pg_nd_stats_from_tuple(HeapTuple stats_tuple, int mode)
N-dimensional statistics structure.

References pg_nd_stats_from_tuple().

Referenced by gserialized_joinsel_internal(), and pg_get_nd_stats_by_name().

Here is the call graph for this function:
Here is the caller graph for this function: