PostGIS  3.3.9dev-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 958 of file gserialized_estimate.c.

959 {
960  HeapTuple stats_tuple = NULL;
961  ND_STATS *nd_stats;
962 
963  /* First pull the stats tuple for the whole tree */
964  if ( ! only_parent )
965  {
966  POSTGIS_DEBUGF(2, "searching whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
967  stats_tuple = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(table_oid), Int16GetDatum(att_num), BoolGetDatum(true));
968  if ( stats_tuple )
969  POSTGIS_DEBUGF(2, "found whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
970  }
971  /* Fall-back to main table stats only, if not found for whole tree or explicitly ignored */
972  if ( only_parent || ! stats_tuple )
973  {
974  POSTGIS_DEBUGF(2, "searching parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
975  stats_tuple = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(table_oid), Int16GetDatum(att_num), BoolGetDatum(false));
976  if ( stats_tuple )
977  POSTGIS_DEBUGF(2, "found parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
978  }
979  if ( ! stats_tuple )
980  {
981  POSTGIS_DEBUGF(2, "stats for \"%s\" do not exist", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
982  return NULL;
983  }
984 
985  nd_stats = pg_nd_stats_from_tuple(stats_tuple, mode);
986  ReleaseSysCache(stats_tuple);
987  if ( ! nd_stats )
988  {
989  POSTGIS_DEBUGF(2,
990  "histogram for attribute %d of table \"%s\" does not exist?",
991  att_num, get_rel_name(table_oid));
992  }
993 
994  return nd_stats;
995 }
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: