PostGIS  2.3.8dev-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 883 of file gserialized_estimate.c.

References pg_nd_stats_from_tuple(), and TRUE.

Referenced by gserialized_gist_joinsel(), and pg_get_nd_stats_by_name().

884 {
885  HeapTuple stats_tuple = NULL;
886  ND_STATS *nd_stats;
887 
888  /* First pull the stats tuple for the whole tree */
889  if ( ! only_parent )
890  {
891  POSTGIS_DEBUGF(2, "searching whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
892  stats_tuple = SearchSysCache3(STATRELATT, table_oid, att_num, TRUE);
893  if ( stats_tuple )
894  POSTGIS_DEBUGF(2, "found whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
895  }
896  /* Fall-back to main table stats only, if not found for whole tree or explicitly ignored */
897  if ( only_parent || ! stats_tuple )
898  {
899  POSTGIS_DEBUGF(2, "searching parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
900  stats_tuple = SearchSysCache2(STATRELATT, table_oid, att_num);
901  if ( stats_tuple )
902  POSTGIS_DEBUGF(2, "found parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
903  }
904  if ( ! stats_tuple )
905  {
906  POSTGIS_DEBUGF(2, "stats for \"%s\" do not exist", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
907  return NULL;
908  }
909 
910  nd_stats = pg_nd_stats_from_tuple(stats_tuple, mode);
911  ReleaseSysCache(stats_tuple);
912  if ( ! nd_stats )
913  {
914  POSTGIS_DEBUGF(2,
915  "histogram for attribute %d of table \"%s\" does not exist?",
916  att_num, get_rel_name(table_oid));
917  }
918 
919  return nd_stats;
920 }
static ND_STATS * pg_nd_stats_from_tuple(HeapTuple stats_tuple, int mode)
N-dimensional statistics structure.
#define TRUE
Definition: dbfopen.c:169
Here is the call graph for this function:
Here is the caller graph for this function: