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 887 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().

888 {
889  HeapTuple stats_tuple = NULL;
890  ND_STATS *nd_stats;
891 
892  /* First pull the stats tuple for the whole tree */
893  if ( ! only_parent )
894  {
895  POSTGIS_DEBUGF(2, "searching whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
896  stats_tuple = SearchSysCache3(STATRELATT, table_oid, att_num, TRUE);
897  if ( stats_tuple )
898  POSTGIS_DEBUGF(2, "found whole tree stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
899  }
900  /* Fall-back to main table stats only, if not found for whole tree or explicitly ignored */
901  if ( only_parent || ! stats_tuple )
902  {
903  POSTGIS_DEBUGF(2, "searching parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
904  stats_tuple = SearchSysCache2(STATRELATT, table_oid, att_num);
905  if ( stats_tuple )
906  POSTGIS_DEBUGF(2, "found parent table stats for \"%s\"", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
907  }
908  if ( ! stats_tuple )
909  {
910  POSTGIS_DEBUGF(2, "stats for \"%s\" do not exist", get_rel_name(table_oid)? get_rel_name(table_oid) : "NULL");
911  return NULL;
912  }
913 
914  nd_stats = pg_nd_stats_from_tuple(stats_tuple, mode);
915  ReleaseSysCache(stats_tuple);
916  if ( ! nd_stats )
917  {
918  POSTGIS_DEBUGF(2,
919  "histogram for attribute %d of table \"%s\" does not exist?",
920  att_num, get_rel_name(table_oid));
921  }
922 
923  return nd_stats;
924 }
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: