1 /*-------------------------------------------------------------------------
4 * Definitions for internal planner nodes.
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: relation.h,v 1.11 1998/09/01 04:36:51 momjian Exp $
11 *-------------------------------------------------------------------------
16 #include <nodes/parsenodes.h>
17 #include <nodes/primnodes.h>
21 * List of relation identifiers (indexes into the rangetable).
28 * Per-base-relation information
30 * Parts of this data structure are specific to various scan and join
31 * mechanisms. It didn't seem worth creating new node types for them.
33 * relids - List of relation indentifiers
34 * indexed - true if the relation has secondary indices
35 * pages - number of pages in the relation
36 * tuples - number of tuples in the relation
37 * size - number of tuples in the relation after restrictions clauses
39 * width - number of bytes per tuple in the relation after the
40 * appropriate projections have been done
41 * targetlist - List of TargetList nodes
42 * pathlist - List of Path nodes, one for each possible method of
43 * generating the relation
44 * unorderedpath - a Path node generating this relation whose resulting
45 * tuples are unordered (this isn't necessarily a
46 * sequential scan path, e.g., scanning with a hash index
47 * leaves the tuples unordered)
48 * cheapestpath - least expensive Path (regardless of final order)
49 * pruneable - flag to let the planner know whether it can prune the plan
50 * space of this RelOptInfo or not. -- JMH, 11/11/92
52 * * If the relation is a (secondary) index it will have the following
55 * classlist - List of PG_AMOPCLASS OIDs for the index
56 * indexkeys - List of base-relation attribute numbers that are index keys
57 * ordering - List of PG_OPERATOR OIDs which order the indexscan result
58 * relam - the OID of the pg_am of the index
60 * * The presence of the remaining fields depends on the restrictions
61 * and joins which the relation participates in:
63 * clauseinfo - List of ClauseInfo nodes, containing info about each
64 * qualification clause in which this relation participates
65 * joininfo - List of JoinInfo nodes, containing info about each join
66 * clause in which this relation participates
67 * innerjoin - List of Path nodes that represent indices that may be used
68 * as inner paths of nestloop joins
70 * NB. the last element of the arrays classlist, indexkeys and ordering
71 * is always 0. 2/95 - ay
74 typedef struct RelOptInfo
81 /* catalog statistics information */
88 /* materialization information */
91 struct Path *unorderedpath;
92 struct Path *cheapestpath;
95 /* used solely by indices: */
96 Oid *classlist; /* classes of AM operators */
97 int *indexkeys; /* keys over which we're indexing */
98 Oid relam; /* OID of the access method (in pg_am) */
103 /* used by various scans and joins: */
104 Oid *ordering; /* OID of operators in sort order */
105 List *clauseinfo; /* restriction clauses */
106 List *joininfo; /* join clauses */
111 extern Var *get_expr(TargetEntry *foo);
113 typedef struct MergeOrder
123 typedef enum OrderType
125 MERGE_ORDER, SORTOP_ORDER
128 typedef struct PathOrder
147 PathOrder p_ordering;
155 typedef struct IndexPath
160 int *indexkeys; /* to transform heap attnos into index
164 typedef struct JoinPath
167 List *pathclauseinfo;
172 typedef struct MergePath
175 List *path_mergeclauses;
180 typedef struct HashPath
183 List *path_hashclauses;
192 typedef struct OrderKey
195 int attribute_number;
199 typedef struct JoinKey
210 typedef struct ClauseInfo
213 Expr *clause; /* should be an OP clause */
219 MergeOrder *mergejoinorder;
222 Oid hashjoinoperator;
226 typedef struct JoinMethod
242 MergeOrder *m_ordering;
245 typedef struct JoinInfo
249 List *jinfoclauseinfo;
259 Oid itertype; /* type of the iter expr (use for type
265 ** A stream represents a root-to-leaf path in a plan tree (i.e. a tree of
266 ** JoinPaths and Paths). The stream includes pointers to all Path nodes,
267 ** as well as to any clauses that reside above Path nodes. This structure
268 ** is used to make Path nodes and clauses look similar, so that Predicate
269 ** Migration can run.
271 ** pathptr -- pointer to the current path node
272 ** cinfo -- if NULL, this stream node referes to the path node.
273 ** Otherwise this is a pointer to the current clause.
274 ** clausetype -- whether cinfo is in locclauseinfo or pathclauseinfo in the
276 ** upstream -- linked list pointer upwards
277 ** downstream -- ditto, downwards
278 ** groupup -- whether or not this node is in a group with the node upstream
279 ** groupcost -- total cost of the group that node is in
280 ** groupsel -- total selectivity of the group that node is in
282 typedef struct Stream *StreamPtr;
284 typedef struct Stream
290 struct Stream *upstream;
291 struct Stream *downstream;
297 #endif /* RELATION_H */