1 /* BEGIN mrds_optimize_tables.incl.pl1 -- jaw, 2/23/79 */
  2 
  3 /* HISTORY:
  4 
  5    81-07-06 Jim Gray : added number  of  tuples  selected,  and  the
  6    access  methods currently available to the path_var structure, to
  7    allow the cost of a search path to be properly calculated.
  8 
  9    81-07-07 Jim Gray : added in_and_group and cost to  path_var  for
 10    handling not in and_group tuple variables.
 11 
 12    81-07-13 Jim Gray : removed calc_cost related structures that are
 13    no  longer  used.  Also  commented  the access methods available.
 14    Added cond_ptr and attr_index to path_var to  make  gen_srch_prog
 15    use access specified by permute.
 16 
 17    81-07-14 Jim Gray : added  condition_selected  and  attr_selected
 18    bits  to  the cond and attr_list structures respectively, so that
 19    the permute logic in gen_srch_prog  could  be  removed,  and  the
 20    desires  of  permute could be passed to gen_srch_prog. Also added
 21    description of structures in this include file.
 22 
 23    81-07-17 Jim Gray : removed unused path_array structure once used
 24    by the discarded calc_cost routine, now replaced by permute.
 25 
 26    81-07-19 Jim Gray : added in_select_clause bit  to  path_var  for
 27    use  by  optimize,  gen_srch_prog  and  the  permute  display for
 28    properly  handling  no_tuple_effect  tuple  variables,  and   not
 29    producing cross products not specified by the user.
 30 
 31    81-07-21 Jim Gray : added a second condition pointer to the  path
 32    var  structure,  so  that  permute could detect, make use of, and
 33    pass on the info for  doing  range  searches  on  key  heads  and
 34    secondary indexes.
 35 
 36    83-04-22 Mike Kubicar : removed attr_list.info.used.  It is no
 37    longer needed.
 38 
 39 */
 40 
 41 
 42 /* DESCRIPTION:
 43 
 44    The  major  structure  of  this  include  file  is  the  path_var
 45    structure.  It is used to hold an ordered list of tuple variables
 46    from the selection expression range clause, in the order in which
 47    they  will  be  used  for  doing  I/O on the database in order to
 48    retrieve the data necessary to evaluate the selection expression.
 49 
 50    The alp in this structure points to the attr_list structure which
 51    contains  a  list of all attributes referenced by this particular
 52    tuple variable in the selection expression.
 53 
 54    The elp in  this  path_var  structure  for  this  tuple  variable
 55    similarly  points  to  the  expr_list  structure,  which contains
 56    information on all expressions in the selection expression  which
 57    reference the tuple variable.
 58 
 59    The attr_list structure in turn has  a  list  of  all  conditions
 60    (comparisons  involving  it)  against  that attribute in a linked
 61    list of cond structures pointed to by the cond_ptr.
 62 
 63    The op_code encoding for thecond and expr_list structures is that
 64    used  in the pred_node structures of the predicate tree, and that
 65    given by the named constants starting OTT_...
 66 
 67    The path_array structure  was  originally  intended  for  use  by
 68    mrds_dsl_calc_cost,  which  is  obsolete. Now only one element is
 69    used to point to the path returned by permute.
 70 
 71 */
 72 
 73 dcl 1 path_var aligned based (pvp),                         /* info on one path through and group */
 74     2 var_index fixed bin,                                  /* index of this var */
 75     2 in_and_group bit (1) unal,                            /* on => this tuple variable participates in the and group */
 76     2 in_select_clause bit (1),                             /* on => this tuple variable selected */
 77     2 pad bit (34) unal,                                    /* for future use */
 78     2 cost float bin (63),                                  /* partial sub path cost, or total for not in and_group */
 79     2 number_tuples_selected fixed bin (35),                /* estimate of tuples selected by access method */
 80     2 access_method fixed bin,                              /* encoding for the method of access to this tuple variable:
 81                                                                1 => unique key search
 82                                                                2 => long key head search, only "=" conditions
 83                                                                3 => short key head, other than "=" conditions
 84                                                                4 => indexed attr
 85                                                                5 => unordered sequential search
 86                                                                6 => ordered sequential search */
 87     2 cond_ptr ptr,                                         /* to condition on this T.V. to be used for accessing it */
 88     2 second_cond_ptr ptr,                                  /* to second condition when a range is specified */
 89     2 attr_index fixed bin,                                 /* attr_ptr array definition order index
 90                                                                of attr to be used for accessing this T.V. */
 91     2 lk_key_ind fixed bin,                                 /* link index or key id */
 92     2 alp ptr,                                              /* to attribute list */
 93     2 elp ptr,                                              /* to expr list */
 94     2 fwd_thd ptr;                                          /* to next in path */
 95 
 96 dcl  pvp ptr;
 97 
 98 
 99 /* ACCESS METHODS AVAILABLE TO MRDS:
100 
101    1) any number of key attributes making up a  total  primary  key,
102    with  at  least  one  "="  condition against each allows use of a
103    vfile seek_key, to find the 1 unique tuple referenced
104 
105    2) any number of key  head  attributes  with  at  least  one  "="
106    condition  against  each  allows  use of vfile select, to find >1
107    tuples whose key has this prefix value
108 
109    3)  the  first  key  head  attribute  having  other  than  a  "="
110    condition,  or  any number of conditions against it allows use of
111    vfile select, to find >1 tuples whose key has this prefix
112 
113    4) a single secondarily indexed attribute with any  condition  or
114    number  of  conditions  against it allows use of vfile select, to
115    find the >= 1 tuples whose values match  that  of  the  value  or
116    range of values given
117 
118    5) an unordered sequential search, where no updates  against  the
119    database  relation  will  be  done allows use of mu_scan_records,
120    which goes through the records without touching the vfile keys
121 
122    6) an ordered sequential search, which must touch the vfile  keys
123    in  order  to  get  the tuple records, thus producing an in-order
124    retrieval
125 
126 */
127 
128 dcl ((TOTAL_PRIMARY_KEY init (1)),
129     (LONG_KEY_HEAD init (2)),
130     (SHORT_KEY_HEAD init (3)),
131     (INDEXED_ATTR init (4)),
132     (UNORDERED_SEQUENTIAL init (5)),
133     (ORDERED_SEQUENTIAL init (6))) fixed bin int static options (constant);
134 
135 dcl 1 attr_list aligned based (alp),                        /* info on all ref. attr. for a t.v. */
136     2 nattr fixed bin,                                      /* number of attrs in rel */
137     2 info (al_nattr_init refer (attr_list.nattr)),         /* definition order array */
138       3 attr_selected bit (1) unal,                         /* on => this attr used by access method chosed */
139       3 pad bit (35) unal,
140       3 index fixed bin,                                    /* definition order, same as array element number  */
141       3 cond_ptr ptr ;                                      /* to list of conditions on attr. */
142 
143 dcl  alp ptr;
144 dcl  al_nattr_init fixed bin;
145 
146 dcl 1 cond aligned based (condp),                           /* info on attr condition */
147     2 op_code fixed bin,                                    /* op code translated from pred_node */
148     2 condition_selected bit (1) unal,                      /* on => this condition used by access method chosen */
149     2 pad bit (35) unal,
150     2 pl_ptr ptr,                                           /* to pred leaf of other attr */
151     2 fwd_thd ptr;                                          /* to next condition */
152 
153 dcl  condp ptr;
154 
155 dcl 1 expr_list aligned based (elp),                        /* info for expr in this var */
156     2 nexprs fixed bin,
157     2 info (el_nexprs_init refer (expr_list.nexprs)),
158       3 epl_ptr ptr,                                        /* to pred leaf for this expr */
159       3 op_code fixed bin,
160       3 reserved bit (36) unal,                             /* for future use */
161       3 pl_ptr ptr;                                         /* to pred leaf of other var */
162 
163 dcl  elp ptr;
164 dcl  el_nexprs_init fixed bin;
165 
166 /* COMPARISON OPERATOR NAMED CONSTANTS:
167 
168    The following named constants represent the comparison  operators
169    "=", "^=", "<", "<=", ">", ">=".
170 
171    They are used in the predicate tree nodes, the cond and expr_list
172    structure, and in gen_srch_prog structures. */
173 
174 dcl ((OTT_EQ init (1)),
175     (OTT_NE init (2)),
176     (OTT_LT init (3)),
177     (OTT_LE init (4)),
178     (OTT_GT init (5)),
179     (OTT_GE init (6))) fixed bin int static options (constant);
180 
181 /* END mrds_optimize_tables.incl.pl1 */
182