summaryrefslogtreecommitdiff
path: root/src/include/nodes/relation.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/nodes/relation.h')
-rw-r--r--src/include/nodes/relation.h106
1 files changed, 63 insertions, 43 deletions
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index 0f143017b2..55850cef5e 100644
--- a/src/include/nodes/relation.h
+++ b/src/include/nodes/relation.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: relation.h,v 1.39 1999/11/23 20:07:02 momjian Exp $
+ * $Id: relation.h,v 1.40 2000/01/09 00:26:44 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -33,13 +33,10 @@ typedef List *Relids;
*
* relids - List of base-relation identifiers; it is a base relation
* if there is just one, a join relation if more than one
- * indexed - true if the relation has secondary indices
- * pages - number of pages in the relation
- * tuples - number of tuples in the relation
- * size - estimated number of tuples in the relation after restriction
- * clauses have been applied
+ * rows - estimated number of tuples in the relation after restriction
+ * clauses have been applied (ie, output rows of a plan for it)
* width - avg. number of bytes per tuple in the relation after the
- * appropriate projections have been done
+ * appropriate projections have been done (ie, output width)
* targetlist - List of TargetList nodes
* pathlist - List of Path nodes, one for each potentially useful
* method of generating the relation
@@ -47,20 +44,11 @@ typedef List *Relids;
* pruneable - flag to let the planner know whether it can prune the
* pathlist of this RelOptInfo or not.
*
- * * If the relation is a (secondary) index it will have the following
- * fields set:
- *
- * classlist - List of PG_AMOPCLASS OIDs for the index
- * indexkeys - List of base-relation attribute numbers that are index keys
- * ordering - List of PG_OPERATOR OIDs which order the indexscan result
- * relam - the OID of the pg_am of the index
- *
- * NB. the last element of the arrays classlist, indexkeys and ordering
- * is always 0.
+ * * If the relation is a base relation it will have these fields set:
*
- * Index relations do not participate in the join tree in the way
- * that regular base relations do, but it is still convenient to
- * represent them by RelOptInfos.
+ * indexed - true if the relation has secondary indices
+ * pages - number of disk pages in relation
+ * tuples - number of tuples in relation (not considering restrictions)
*
* * The presence of the remaining fields depends on the restrictions
* and joins that the relation participates in:
@@ -79,16 +67,11 @@ typedef struct RelOptInfo
NodeTag type;
/* all relations included in this RelOptInfo */
- Relids relids; /* integer list of base relids */
-
- /* catalog statistics information */
- bool indexed;
- int pages;
- int tuples;
+ Relids relids; /* integer list of base relids (RT indexes) */
- /* estimates generated by planner. XXX int is probably too small... */
- int size;
- int width;
+ /* size estimates generated by planner */
+ double rows; /* estimated number of result tuples */
+ int width; /* estimated avg width of result tuples */
/* materialization information */
List *targetlist;
@@ -96,14 +79,10 @@ typedef struct RelOptInfo
struct Path *cheapestpath;
bool pruneable;
- /* used solely by indices: */
- Oid *classlist; /* classes of AM operators */
- int *indexkeys; /* keys over which we're indexing */
- Oid *ordering; /* OIDs of sort operators for each key */
- Oid relam; /* OID of the access method (in pg_am) */
-
- Oid indproc; /* if a functional index */
- List *indpred; /* if a partial index */
+ /* statistics from pg_class (only valid if it's a base rel!) */
+ bool indexed;
+ long pages;
+ double tuples;
/* used by various scans and joins: */
List *restrictinfo; /* RestrictInfo structures */
@@ -116,6 +95,48 @@ typedef struct RelOptInfo
} RelOptInfo;
/*
+ * IndexOptInfo
+ * Per-index information for planning/optimization
+ *
+ * Prior to Postgres 7.0, RelOptInfo was used to describe both relations
+ * and indexes, but that created confusion without actually doing anything
+ * useful. So now we have a separate IndexOptInfo struct for indexes.
+ *
+ * indexoid - OID of the index relation itself
+ * pages - number of disk pages in index
+ * tuples - number of index tuples in index
+ * classlist - List of PG_AMOPCLASS OIDs for the index
+ * indexkeys - List of base-relation attribute numbers that are index keys
+ * ordering - List of PG_OPERATOR OIDs which order the indexscan result
+ * relam - the OID of the pg_am of the index
+ * indproc - OID of the function if a functional index, else 0
+ * indpred - index predicate if a partial index, else NULL
+ *
+ * NB. the last element of the arrays classlist, indexkeys and ordering
+ * is always 0.
+ */
+
+typedef struct IndexOptInfo
+{
+ NodeTag type;
+
+ Oid indexoid; /* OID of the index relation */
+
+ /* statistics from pg_class */
+ long pages;
+ double tuples;
+
+ /* index descriptor information */
+ Oid *classlist; /* classes of AM operators */
+ int *indexkeys; /* keys over which we're indexing */
+ Oid *ordering; /* OIDs of sort operators for each key */
+ Oid relam; /* OID of the access method (in pg_am) */
+
+ Oid indproc; /* if a functional index */
+ List *indpred; /* if a partial index */
+} IndexOptInfo;
+
+/*
* PathKeys
*
* The sort ordering of a path is represented by a list of sublists of
@@ -208,8 +229,6 @@ typedef struct JoinPath
{
Path path;
- List *pathinfo; /* copy of parent->restrictinfo; REMOVE? */
-
Path *outerjoinpath; /* path for the outer side of the join */
Path *innerjoinpath; /* path for the inner side of the join */
} JoinPath;
@@ -296,10 +315,10 @@ typedef struct RestrictInfo
NodeTag type;
Expr *clause; /* the represented clause of WHERE cond */
- Cost selectivity; /* estimated selectivity */
/* only used if clause is an OR clause: */
- List *subclauseindices; /* lists of indexes matching subclauses */
+ List *subclauseindices; /* indexes matching subclauses */
+ /* subclauseindices is a List of Lists of IndexOptInfos */
/* valid if clause is mergejoinable, else InvalidOid: */
Oid mergejoinoperator; /* copy of clause operator */
@@ -346,7 +365,8 @@ typedef struct JoinInfo
* cinfo -- if NULL, this stream node referes to the path node.
* Otherwise this is a pointer to the current clause.
* clausetype -- whether cinfo is in loc_restrictinfo or pathinfo in the
- * path node (XXX this is now used only by dead code...)
+ * path node (XXX this is now used only by dead code, which is
+ * good because the distinction no longer exists...)
* upstream -- linked list pointer upwards
* downstream -- ditto, downwards
* groupup -- whether or not this node is in a group with the node upstream
@@ -365,7 +385,7 @@ typedef struct Stream
StreamPtr downstream;
bool groupup;
Cost groupcost;
- Cost groupsel;
+ Selectivity groupsel;
} Stream;
#endif /* RELATION_H */