PostGIS  2.5.0dev-r@@SVN_REVISION@@
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 929 of file gserialized_estimate.c.

References pg_nd_stats_from_tuple().

Referenced by gserialized_gist_joinsel(), and pg_get_nd_stats_by_name().

930 {
931  HeapTuple stats_tuple = NULL;
932  ND_STATS *nd_stats;
933 
934  /* First pull the stats tuple for the whole tree */
935  if ( ! only_parent )
936  {
937  POSTGIS_DEBUGF(2, "searching whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
938  stats_tuple = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(table_oid), Int16GetDatum(att_num), BoolGetDatum(true));
939  if ( stats_tuple )
940  POSTGIS_DEBUGF(2, "found whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
941  }
942  /* Fall-back to main table stats only, if not found for whole tree or explicitly ignored */
943  if ( only_parent || ! stats_tuple )
944  {
945  POSTGIS_DEBUGF(2, "searching parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
946  stats_tuple = SearchSysCache3(STATRELATTINH, ObjectIdGetDatum(table_oid), Int16GetDatum(att_num), BoolGetDatum(false));
947  if ( stats_tuple )
948  POSTGIS_DEBUGF(2, "found parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
949  }
950  if ( ! stats_tuple )
951  {
952  POSTGIS_DEBUGF(2, "stats for \"%s\" do not exist", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
953  return NULL;
954  }
955 
956  nd_stats = pg_nd_stats_from_tuple(stats_tuple, mode);
957  ReleaseSysCache(stats_tuple);
958  if ( ! nd_stats )
959  {
960  POSTGIS_DEBUGF(2,
961  "histogram for attribute %d of table \"%s\" does not exist?",
962  att_num, get_rel_name(table_oid));
963  }
964 
965  return nd_stats;
966 }
static ND_STATS * pg_nd_stats_from_tuple(HeapTuple stats_tuple, int mode)
N-dimensional statistics structure.

Here is the call graph for this function:

Here is the caller graph for this function: