Optimizer rename ClauseInfo -> RestrictInfo. Update optimizer README.
This commit is contained in:
parent
f3a6b38e32
commit
8d9237d485
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.31 1999/02/02 03:44:19 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.32 1999/02/03 20:15:20 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
#include <access/heapam.h>
|
#include <access/heapam.h>
|
||||||
#include <utils/builtins.h>
|
#include <utils/builtins.h>
|
||||||
#include <utils/syscache.h>
|
#include <utils/syscache.h>
|
||||||
|
#include <catalog/heap.h>
|
||||||
#include <catalog/index.h>
|
#include <catalog/index.h>
|
||||||
#include <catalog/pg_index.h>
|
#include <catalog/pg_index.h>
|
||||||
#include <catalog/pg_proc.h>
|
#include <catalog/pg_proc.h>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* copyfuncs.c--
|
* copyfuncs.c--
|
||||||
* Copy functions for Postgres tree nodes.
|
* Copy functions for Postgres tree nodes.
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.57 1999/02/02 03:44:26 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.58 1999/02/03 20:15:20 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -1064,7 +1064,7 @@ _copyRelOptInfo(RelOptInfo * from)
|
||||||
newnode->ordering[len] = 0;
|
newnode->ordering[len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node_Copy(from, newnode, clauseinfo);
|
Node_Copy(from, newnode, restrictinfo);
|
||||||
Node_Copy(from, newnode, joininfo);
|
Node_Copy(from, newnode, joininfo);
|
||||||
Node_Copy(from, newnode, innerjoin);
|
Node_Copy(from, newnode, innerjoin);
|
||||||
Node_Copy(from, newnode, superrels);
|
Node_Copy(from, newnode, superrels);
|
||||||
|
@ -1119,7 +1119,7 @@ CopyPathFields(Path *from, Path *newnode)
|
||||||
newnode->outerjoincost = from->outerjoincost;
|
newnode->outerjoincost = from->outerjoincost;
|
||||||
|
|
||||||
newnode->joinid = listCopy(from->joinid);
|
newnode->joinid = listCopy(from->joinid);
|
||||||
Node_Copy(from, newnode, locclauseinfo);
|
Node_Copy(from, newnode, loc_restrictinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
|
@ -1184,7 +1184,7 @@ _copyIndexPath(IndexPath *from)
|
||||||
static void
|
static void
|
||||||
CopyJoinPathFields(JoinPath *from, JoinPath *newnode)
|
CopyJoinPathFields(JoinPath *from, JoinPath *newnode)
|
||||||
{
|
{
|
||||||
Node_Copy(from, newnode, pathclauseinfo);
|
Node_Copy(from, newnode, pathinfo);
|
||||||
Node_Copy(from, newnode, outerjoinpath);
|
Node_Copy(from, newnode, outerjoinpath);
|
||||||
Node_Copy(from, newnode, innerjoinpath);
|
Node_Copy(from, newnode, innerjoinpath);
|
||||||
}
|
}
|
||||||
|
@ -1324,13 +1324,13 @@ _copyMergeOrder(MergeOrder *from)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* _copyClauseInfo
|
* _copyRestrictInfo
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
static ClauseInfo *
|
static RestrictInfo *
|
||||||
_copyClauseInfo(ClauseInfo * from)
|
_copyRestrictInfo(RestrictInfo * from)
|
||||||
{
|
{
|
||||||
ClauseInfo *newnode = makeNode(ClauseInfo);
|
RestrictInfo *newnode = makeNode(RestrictInfo);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* copy remainder of node
|
* copy remainder of node
|
||||||
|
@ -1430,7 +1430,7 @@ _copyJoinInfo(JoinInfo * from)
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
newnode->otherrels = listCopy(from->otherrels);
|
newnode->otherrels = listCopy(from->otherrels);
|
||||||
Node_Copy(from, newnode, jinfoclauseinfo);
|
Node_Copy(from, newnode, jinfo_restrictinfo);
|
||||||
|
|
||||||
newnode->mergejoinable = from->mergejoinable;
|
newnode->mergejoinable = from->mergejoinable;
|
||||||
newnode->hashjoinable = from->hashjoinable;
|
newnode->hashjoinable = from->hashjoinable;
|
||||||
|
@ -1792,8 +1792,8 @@ copyObject(void *from)
|
||||||
case T_MergeOrder:
|
case T_MergeOrder:
|
||||||
retval = _copyMergeOrder(from);
|
retval = _copyMergeOrder(from);
|
||||||
break;
|
break;
|
||||||
case T_ClauseInfo:
|
case T_RestrictInfo:
|
||||||
retval = _copyClauseInfo(from);
|
retval = _copyRestrictInfo(from);
|
||||||
break;
|
break;
|
||||||
case T_JoinMethod:
|
case T_JoinMethod:
|
||||||
retval = _copyJoinMethod(from);
|
retval = _copyJoinMethod(from);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.21 1999/02/02 23:53:25 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.22 1999/02/03 20:15:22 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -278,13 +278,13 @@ _equalFunc(Func *a, Func *b)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ClauseInfo is a subclass of Node.
|
* RestrictInfo is a subclass of Node.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
_equalClauseInfo(ClauseInfo * a, ClauseInfo * b)
|
_equalRestrictInfo(RestrictInfo * a, RestrictInfo * b)
|
||||||
{
|
{
|
||||||
Assert(IsA(a, ClauseInfo));
|
Assert(IsA(a, RestrictInfo));
|
||||||
Assert(IsA(b, ClauseInfo));
|
Assert(IsA(b, RestrictInfo));
|
||||||
|
|
||||||
if (!equal(a->clause, b->clause))
|
if (!equal(a->clause, b->clause))
|
||||||
return false;
|
return false;
|
||||||
|
@ -298,8 +298,7 @@ _equalClauseInfo(ClauseInfo * a, ClauseInfo * b)
|
||||||
#endif
|
#endif
|
||||||
if (a->hashjoinoperator != b->hashjoinoperator)
|
if (a->hashjoinoperator != b->hashjoinoperator)
|
||||||
return false;
|
return false;
|
||||||
return (equal((a->indexids),
|
return equal(a->indexids, b->indexids);
|
||||||
(b->indexids)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -311,8 +310,7 @@ _equalRelOptInfo(RelOptInfo * a, RelOptInfo * b)
|
||||||
Assert(IsA(a, RelOptInfo));
|
Assert(IsA(a, RelOptInfo));
|
||||||
Assert(IsA(b, RelOptInfo));
|
Assert(IsA(b, RelOptInfo));
|
||||||
|
|
||||||
return (equal((a->relids),
|
return equal(a->relids, b->relids);
|
||||||
(b->relids)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -321,11 +319,9 @@ _equalJoinMethod(JoinMethod *a, JoinMethod *b)
|
||||||
Assert(IsA(a, JoinMethod));
|
Assert(IsA(a, JoinMethod));
|
||||||
Assert(IsA(b, JoinMethod));
|
Assert(IsA(b, JoinMethod));
|
||||||
|
|
||||||
if (!equal((a->jmkeys),
|
if (!equal(a->jmkeys, b->jmkeys))
|
||||||
(b->jmkeys)))
|
|
||||||
return false;
|
return false;
|
||||||
if (!equal((a->clauses),
|
if (!equal(a->clauses, b->clauses))
|
||||||
(b->clauses)))
|
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -368,19 +364,16 @@ _equalPath(Path *a, Path *b)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!equal((a->p_ordering.ord.merge),
|
if (!equal(a->p_ordering.ord.merge, b->p_ordering.ord.merge))
|
||||||
(b->p_ordering.ord.merge)))
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!equal((a->keys),
|
if (!equal(a->keys, b->keys))
|
||||||
(b->keys)))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if (a->outerjoincost != b->outerjoincost) return(false);
|
* if (a->outerjoincost != b->outerjoincost) return(false);
|
||||||
*/
|
*/
|
||||||
if (!equali((a->joinid),
|
if (!equali(a->joinid, b->joinid))
|
||||||
(b->joinid)))
|
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -390,9 +383,9 @@ _equalIndexPath(IndexPath *a, IndexPath *b)
|
||||||
{
|
{
|
||||||
if (!_equalPath((Path *) a, (Path *) b))
|
if (!_equalPath((Path *) a, (Path *) b))
|
||||||
return false;
|
return false;
|
||||||
if (!equali((a->indexid), (b->indexid)))
|
if (!equali(a->indexid, b->indexid))
|
||||||
return false;
|
return false;
|
||||||
if (!equal((a->indexqual), (b->indexqual)))
|
if (!equal(a->indexqual, b->indexqual))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -405,11 +398,11 @@ _equalJoinPath(JoinPath *a, JoinPath *b)
|
||||||
|
|
||||||
if (!_equalPath((Path *) a, (Path *) b))
|
if (!_equalPath((Path *) a, (Path *) b))
|
||||||
return false;
|
return false;
|
||||||
if (!equal((a->pathclauseinfo), (b->pathclauseinfo)))
|
if (!equal(a->pathinfo, b->pathinfo))
|
||||||
return false;
|
return false;
|
||||||
if (!equal((a->outerjoinpath), (b->outerjoinpath)))
|
if (!equal(a->outerjoinpath, b->outerjoinpath))
|
||||||
return false;
|
return false;
|
||||||
if (!equal((a->innerjoinpath), (b->innerjoinpath)))
|
if (!equal(a->innerjoinpath, b->innerjoinpath))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -454,9 +447,9 @@ _equalJoinKey(JoinKey *a, JoinKey *b)
|
||||||
Assert(IsA(a, JoinKey));
|
Assert(IsA(a, JoinKey));
|
||||||
Assert(IsA(b, JoinKey));
|
Assert(IsA(b, JoinKey));
|
||||||
|
|
||||||
if (!equal((a->outer), (b->outer)))
|
if (!equal(a->outer, b->outer))
|
||||||
return false;
|
return false;
|
||||||
if (!equal((a->inner), (b->inner)))
|
if (!equal(a->inner, b->inner))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -506,13 +499,13 @@ _equalIndexScan(IndexScan *a, IndexScan *b)
|
||||||
* if(a->scan.plan.cost != b->scan.plan.cost) return(false);
|
* if(a->scan.plan.cost != b->scan.plan.cost) return(false);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!equal((a->indxqual), (b->indxqual)))
|
if (!equal(a->indxqual, b->indxqual))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (a->scan.scanrelid != b->scan.scanrelid)
|
if (a->scan.scanrelid != b->scan.scanrelid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!equali((a->indxid), (b->indxid)))
|
if (!equali(a->indxid, b->indxid))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -523,7 +516,7 @@ _equalSubPlan(SubPlan *a, SubPlan *b)
|
||||||
if (a->plan_id != b->plan_id)
|
if (a->plan_id != b->plan_id)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!equal((a->sublink->oper), (b->sublink->oper)))
|
if (!equal(a->sublink->oper, b->sublink->oper))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -534,9 +527,9 @@ _equalJoinInfo(JoinInfo * a, JoinInfo * b)
|
||||||
{
|
{
|
||||||
Assert(IsA(a, JoinInfo));
|
Assert(IsA(a, JoinInfo));
|
||||||
Assert(IsA(b, JoinInfo));
|
Assert(IsA(b, JoinInfo));
|
||||||
if (!equal((a->otherrels), (b->otherrels)))
|
if (!equal(a->otherrels, b->otherrels))
|
||||||
return false;
|
return false;
|
||||||
if (!equal((a->jinfoclauseinfo), (b->jinfoclauseinfo)))
|
if (!equal(a->jinfo_restrictinfo, b->jinfo_restrictinfo))
|
||||||
return false;
|
return false;
|
||||||
if (a->mergejoinable != b->mergejoinable)
|
if (a->mergejoinable != b->mergejoinable)
|
||||||
return false;
|
return false;
|
||||||
|
@ -673,8 +666,8 @@ equal(void *a, void *b)
|
||||||
case T_Func:
|
case T_Func:
|
||||||
retval = _equalFunc(a, b);
|
retval = _equalFunc(a, b);
|
||||||
break;
|
break;
|
||||||
case T_ClauseInfo:
|
case T_RestrictInfo:
|
||||||
retval = _equalClauseInfo(a, b);
|
retval = _equalRestrictInfo(a, b);
|
||||||
break;
|
break;
|
||||||
case T_RelOptInfo:
|
case T_RelOptInfo:
|
||||||
retval = _equalRelOptInfo(a, b);
|
retval = _equalRelOptInfo(a, b);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: outfuncs.c,v 1.62 1999/02/02 03:44:26 momjian Exp $
|
* $Id: outfuncs.c,v 1.63 1999/02/03 20:15:22 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Every (plan) node in POSTGRES has an associated "out" routine which
|
* Every (plan) node in POSTGRES has an associated "out" routine which
|
||||||
|
@ -879,11 +879,11 @@ _outRelOptInfo(StringInfo str, RelOptInfo * node)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
appendStringInfo(str,
|
appendStringInfo(str,
|
||||||
" :unorderedpath @ 0x%x :cheapestpath @ 0x%x :pruneable %s :clauseinfo ",
|
" :unorderedpath @ 0x%x :cheapestpath @ 0x%x :pruneable %s :restrictinfo ",
|
||||||
(int) node->unorderedpath,
|
(int) node->unorderedpath,
|
||||||
(int) node->cheapestpath,
|
(int) node->cheapestpath,
|
||||||
node->pruneable ? "true" : "false");
|
node->pruneable ? "true" : "false");
|
||||||
_outNode(str, node->clauseinfo);
|
_outNode(str, node->restrictinfo);
|
||||||
|
|
||||||
appendStringInfo(str, " :joininfo ");
|
appendStringInfo(str, " :joininfo ");
|
||||||
_outNode(str, node->joininfo);
|
_outNode(str, node->joininfo);
|
||||||
|
@ -967,8 +967,8 @@ _outJoinPath(StringInfo str, JoinPath *node)
|
||||||
node->path.path_cost);
|
node->path.path_cost);
|
||||||
_outNode(str, node->path.keys);
|
_outNode(str, node->path.keys);
|
||||||
|
|
||||||
appendStringInfo(str, " :pathclauseinfo ");
|
appendStringInfo(str, " :pathinfo ");
|
||||||
_outNode(str, node->pathclauseinfo);
|
_outNode(str, node->pathinfo);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Not sure if these are nodes; they're declared as "struct path *".
|
* Not sure if these are nodes; they're declared as "struct path *".
|
||||||
|
@ -995,8 +995,8 @@ _outMergePath(StringInfo str, MergePath *node)
|
||||||
node->jpath.path.path_cost);
|
node->jpath.path.path_cost);
|
||||||
_outNode(str, node->jpath.path.keys);
|
_outNode(str, node->jpath.path.keys);
|
||||||
|
|
||||||
appendStringInfo(str, " :pathclauseinfo ");
|
appendStringInfo(str, " :pathinfo ");
|
||||||
_outNode(str, node->jpath.pathclauseinfo);
|
_outNode(str, node->jpath.pathinfo);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Not sure if these are nodes; they're declared as "struct path *".
|
* Not sure if these are nodes; they're declared as "struct path *".
|
||||||
|
@ -1032,8 +1032,8 @@ _outHashPath(StringInfo str, HashPath *node)
|
||||||
node->jpath.path.path_cost);
|
node->jpath.path.path_cost);
|
||||||
_outNode(str, node->jpath.path.keys);
|
_outNode(str, node->jpath.path.keys);
|
||||||
|
|
||||||
appendStringInfo(str, " :pathclauseinfo ");
|
appendStringInfo(str, " :pathinfo ");
|
||||||
_outNode(str, node->jpath.pathclauseinfo);
|
_outNode(str, node->jpath.pathinfo);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Not sure if these are nodes; they're declared as "struct path *".
|
* Not sure if these are nodes; they're declared as "struct path *".
|
||||||
|
@ -1102,10 +1102,10 @@ _outMergeOrder(StringInfo str, MergeOrder *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ClauseInfo is a subclass of Node.
|
* RestrictInfo is a subclass of Node.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
_outClauseInfo(StringInfo str, ClauseInfo * node)
|
_outRestrictInfo(StringInfo str, RestrictInfo * node)
|
||||||
{
|
{
|
||||||
appendStringInfo(str, " CINFO :clause ");
|
appendStringInfo(str, " CINFO :clause ");
|
||||||
_outNode(str, node->clause);
|
_outNode(str, node->clause);
|
||||||
|
@ -1158,8 +1158,8 @@ _outJoinInfo(StringInfo str, JoinInfo * node)
|
||||||
appendStringInfo(str, " JINFO :otherrels ");
|
appendStringInfo(str, " JINFO :otherrels ");
|
||||||
_outIntList(str, node->otherrels);
|
_outIntList(str, node->otherrels);
|
||||||
|
|
||||||
appendStringInfo(str, " :jinfoclauseinfo ");
|
appendStringInfo(str, " :jinfo_restrictinfo ");
|
||||||
_outNode(str, node->jinfoclauseinfo);
|
_outNode(str, node->jinfo_restrictinfo);
|
||||||
|
|
||||||
appendStringInfo(str, " :mergejoinable %s :hashjoinable %s ",
|
appendStringInfo(str, " :mergejoinable %s :hashjoinable %s ",
|
||||||
node->mergejoinable ? "true" : "false",
|
node->mergejoinable ? "true" : "false",
|
||||||
|
@ -1572,8 +1572,8 @@ _outNode(StringInfo str, void *obj)
|
||||||
case T_MergeOrder:
|
case T_MergeOrder:
|
||||||
_outMergeOrder(str, obj);
|
_outMergeOrder(str, obj);
|
||||||
break;
|
break;
|
||||||
case T_ClauseInfo:
|
case T_RestrictInfo:
|
||||||
_outClauseInfo(str, obj);
|
_outRestrictInfo(str, obj);
|
||||||
break;
|
break;
|
||||||
case T_JoinMethod:
|
case T_JoinMethod:
|
||||||
_outJoinMethod(str, obj);
|
_outJoinMethod(str, obj);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.44 1999/02/02 03:44:27 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.45 1999/02/03 20:15:22 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Most of the read functions for plan nodes are tested. (In fact, they
|
* Most of the read functions for plan nodes are tested. (In fact, they
|
||||||
|
@ -1348,8 +1348,8 @@ _readRelOptInfo()
|
||||||
sscanf(token, "%x", (unsigned int *) &local_node->cheapestpath);
|
sscanf(token, "%x", (unsigned int *) &local_node->cheapestpath);
|
||||||
|
|
||||||
|
|
||||||
token = lsptok(NULL, &length); /* get :clauseinfo */
|
token = lsptok(NULL, &length); /* get :restrictinfo */
|
||||||
local_node->clauseinfo = nodeRead(true); /* now read it */
|
local_node->restrictinfo = nodeRead(true); /* now read it */
|
||||||
|
|
||||||
token = lsptok(NULL, &length); /* get :joininfo */
|
token = lsptok(NULL, &length); /* get :joininfo */
|
||||||
local_node->joininfo = nodeRead(true); /* now read it */
|
local_node->joininfo = nodeRead(true); /* now read it */
|
||||||
|
@ -1560,8 +1560,8 @@ _readJoinPath()
|
||||||
token = lsptok(NULL, &length); /* get :keys */
|
token = lsptok(NULL, &length); /* get :keys */
|
||||||
local_node->path.keys = nodeRead(true); /* now read it */
|
local_node->path.keys = nodeRead(true); /* now read it */
|
||||||
|
|
||||||
token = lsptok(NULL, &length); /* get :pathclauseinfo */
|
token = lsptok(NULL, &length); /* get :pathinfo */
|
||||||
local_node->pathclauseinfo = nodeRead(true); /* now read it */
|
local_node->pathinfo = nodeRead(true); /* now read it */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Not sure if these are nodes; they're declared as "struct path *".
|
* Not sure if these are nodes; they're declared as "struct path *".
|
||||||
|
@ -1628,8 +1628,8 @@ _readMergePath()
|
||||||
token = lsptok(NULL, &length); /* get :keys */
|
token = lsptok(NULL, &length); /* get :keys */
|
||||||
local_node->jpath.path.keys = nodeRead(true); /* now read it */
|
local_node->jpath.path.keys = nodeRead(true); /* now read it */
|
||||||
|
|
||||||
token = lsptok(NULL, &length); /* get :pathclauseinfo */
|
token = lsptok(NULL, &length); /* get :pathinfo */
|
||||||
local_node->jpath.pathclauseinfo = nodeRead(true); /* now read it */
|
local_node->jpath.pathinfo = nodeRead(true); /* now read it */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Not sure if these are nodes; they're declared as "struct path *".
|
* Not sure if these are nodes; they're declared as "struct path *".
|
||||||
|
@ -1705,8 +1705,8 @@ _readHashPath()
|
||||||
token = lsptok(NULL, &length); /* get :keys */
|
token = lsptok(NULL, &length); /* get :keys */
|
||||||
local_node->jpath.path.keys = nodeRead(true); /* now read it */
|
local_node->jpath.path.keys = nodeRead(true); /* now read it */
|
||||||
|
|
||||||
token = lsptok(NULL, &length); /* get :pathclauseinfo */
|
token = lsptok(NULL, &length); /* get :pathinfo */
|
||||||
local_node->jpath.pathclauseinfo = nodeRead(true); /* now read it */
|
local_node->jpath.pathinfo = nodeRead(true); /* now read it */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Not sure if these are nodes; they're declared as "struct path *".
|
* Not sure if these are nodes; they're declared as "struct path *".
|
||||||
|
@ -1844,19 +1844,19 @@ _readMergeOrder()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* _readClauseInfo
|
* _readRestrictInfo
|
||||||
*
|
*
|
||||||
* ClauseInfo is a subclass of Node.
|
* RestrictInfo is a subclass of Node.
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
static ClauseInfo *
|
static RestrictInfo *
|
||||||
_readClauseInfo()
|
_readRestrictInfo()
|
||||||
{
|
{
|
||||||
ClauseInfo *local_node;
|
RestrictInfo *local_node;
|
||||||
char *token;
|
char *token;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
local_node = makeNode(ClauseInfo);
|
local_node = makeNode(RestrictInfo);
|
||||||
|
|
||||||
token = lsptok(NULL, &length); /* get :clause */
|
token = lsptok(NULL, &length); /* get :clause */
|
||||||
local_node->clause = nodeRead(true); /* now read it */
|
local_node->clause = nodeRead(true); /* now read it */
|
||||||
|
@ -1960,8 +1960,8 @@ _readJoinInfo()
|
||||||
local_node->otherrels =
|
local_node->otherrels =
|
||||||
toIntList(nodeRead(true)); /* now read it */
|
toIntList(nodeRead(true)); /* now read it */
|
||||||
|
|
||||||
token = lsptok(NULL, &length); /* get :jinfoclauseinfo */
|
token = lsptok(NULL, &length); /* get :jinfo_restrictinfo */
|
||||||
local_node->jinfoclauseinfo = nodeRead(true); /* now read it */
|
local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */
|
||||||
|
|
||||||
token = lsptok(NULL, &length); /* get :mergejoinable */
|
token = lsptok(NULL, &length); /* get :mergejoinable */
|
||||||
|
|
||||||
|
@ -2096,7 +2096,7 @@ parsePlanString(void)
|
||||||
else if (!strncmp(token, "MERGEORDER", length))
|
else if (!strncmp(token, "MERGEORDER", length))
|
||||||
return_value = _readMergeOrder();
|
return_value = _readMergeOrder();
|
||||||
else if (!strncmp(token, "CLAUSEINFO", length))
|
else if (!strncmp(token, "CLAUSEINFO", length))
|
||||||
return_value = _readClauseInfo();
|
return_value = _readRestrictInfo();
|
||||||
else if (!strncmp(token, "JOINMETHOD", length))
|
else if (!strncmp(token, "JOINMETHOD", length))
|
||||||
return_value = _readJoinMethod();
|
return_value = _readJoinMethod();
|
||||||
else if (!strncmp(token, "JOININFO", length))
|
else if (!strncmp(token, "JOININFO", length))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Thse directories take the Query structure returned by the parser, and
|
These directories take the Query structure returned by the parser, and
|
||||||
generate a plan used by the executor. The /plan directory generates the
|
generate a plan used by the executor. The /plan directory generates the
|
||||||
plan, the /path generates all possible ways to join the tables, and
|
plan, the /path generates all possible ways to join the tables, and
|
||||||
/prep handles special cases like inheritance. /utils is utility stuff.
|
/prep handles special cases like inheritance. /utils is utility stuff.
|
||||||
|
@ -81,10 +81,20 @@ planner()
|
||||||
remove from the join list the relation we just added to each join
|
remove from the join list the relation we just added to each join
|
||||||
prune_rel_paths()
|
prune_rel_paths()
|
||||||
set cheapest and perhaps remove unordered path, recompute table sizes
|
set cheapest and perhaps remove unordered path, recompute table sizes
|
||||||
if we have not done all the tables, go to "again"
|
if we have not done all the tables, go to again:
|
||||||
do group(GROUP)
|
do group(GROUP)
|
||||||
do aggregate
|
do aggregate
|
||||||
put back constants
|
put back constants
|
||||||
re-flatten target list
|
re-flatten target list
|
||||||
make unique(DISTINCT)
|
make unique(DISTINCT)
|
||||||
make sort(ORDER BY)
|
make sort(ORDER BY)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Optimizer Structures
|
||||||
|
--------------------
|
||||||
|
Path - info about every way to access a relation(sequential, index)
|
||||||
|
PathOrder - info about every ordering (sort, merge of relations)
|
||||||
|
RelOptInfo - info about every relation
|
||||||
|
JoinInfo - info about join combinations
|
||||||
|
RestrictInfo - info about restrictions
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: geqo_eval.c,v 1.24 1998/09/01 04:29:16 momjian Exp $
|
* $Id: geqo_eval.c,v 1.25 1999/02/03 20:15:24 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -290,7 +290,7 @@ init_join_rel(RelOptInfo * outer_rel, RelOptInfo * inner_rel, JoinInfo * joininf
|
||||||
joinrel->classlist = NULL;
|
joinrel->classlist = NULL;
|
||||||
joinrel->relam = InvalidOid;
|
joinrel->relam = InvalidOid;
|
||||||
joinrel->ordering = NULL;
|
joinrel->ordering = NULL;
|
||||||
joinrel->clauseinfo = NIL;
|
joinrel->restrictinfo = NIL;
|
||||||
joinrel->joininfo = NULL;
|
joinrel->joininfo = NULL;
|
||||||
joinrel->innerjoin = NIL;
|
joinrel->innerjoin = NIL;
|
||||||
joinrel->superrels = NIL;
|
joinrel->superrels = NIL;
|
||||||
|
@ -302,7 +302,7 @@ init_join_rel(RelOptInfo * outer_rel, RelOptInfo * inner_rel, JoinInfo * joininf
|
||||||
|
|
||||||
if (joininfo)
|
if (joininfo)
|
||||||
{
|
{
|
||||||
joinrel->clauseinfo = joininfo->jinfoclauseinfo;
|
joinrel->restrictinfo = joininfo->jinfo_restrictinfo;
|
||||||
if (BushyPlanFlag)
|
if (BushyPlanFlag)
|
||||||
joininfo->inactive = true;
|
joininfo->inactive = true;
|
||||||
}
|
}
|
||||||
|
@ -410,22 +410,18 @@ new_joininfo_list(List *joininfo_list, List *join_relids)
|
||||||
current_joininfo_list);
|
current_joininfo_list);
|
||||||
if (other_joininfo)
|
if (other_joininfo)
|
||||||
{
|
{
|
||||||
other_joininfo->jinfoclauseinfo =
|
other_joininfo->jinfo_restrictinfo =
|
||||||
(List *) LispUnion(joininfo->jinfoclauseinfo,
|
(List *) LispUnion(joininfo->jinfo_restrictinfo,
|
||||||
other_joininfo->jinfoclauseinfo);
|
other_joininfo->jinfo_restrictinfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
other_joininfo = makeNode(JoinInfo);
|
other_joininfo = makeNode(JoinInfo);
|
||||||
|
|
||||||
other_joininfo->otherrels =
|
other_joininfo->otherrels = joininfo->otherrels;
|
||||||
joininfo->otherrels;
|
other_joininfo->jinfo_restrictinfo = joininfo->jinfo_restrictinfo;
|
||||||
other_joininfo->jinfoclauseinfo =
|
other_joininfo->mergejoinable = joininfo->mergejoinable;
|
||||||
joininfo->jinfoclauseinfo;
|
other_joininfo->hashjoinable = joininfo->hashjoinable;
|
||||||
other_joininfo->mergejoinable =
|
|
||||||
joininfo->mergejoinable;
|
|
||||||
other_joininfo->hashjoinable =
|
|
||||||
joininfo->hashjoinable;
|
|
||||||
other_joininfo->inactive = false;
|
other_joininfo->inactive = false;
|
||||||
|
|
||||||
current_joininfo_list = lcons(other_joininfo,
|
current_joininfo_list = lcons(other_joininfo,
|
||||||
|
@ -508,7 +504,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
|
||||||
{
|
{
|
||||||
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
|
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
|
||||||
List *other_rels = joininfo->otherrels;
|
List *other_rels = joininfo->otherrels;
|
||||||
List *clause_info = joininfo->jinfoclauseinfo;
|
List *restrict_info = joininfo->jinfo_restrictinfo;
|
||||||
bool mergejoinable = joininfo->mergejoinable;
|
bool mergejoinable = joininfo->mergejoinable;
|
||||||
bool hashjoinable = joininfo->hashjoinable;
|
bool hashjoinable = joininfo->hashjoinable;
|
||||||
|
|
||||||
|
@ -540,7 +536,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
|
||||||
new_joininfo = makeNode(JoinInfo);
|
new_joininfo = makeNode(JoinInfo);
|
||||||
|
|
||||||
new_joininfo->otherrels = joinrel->relids;
|
new_joininfo->otherrels = joinrel->relids;
|
||||||
new_joininfo->jinfoclauseinfo = clause_info;
|
new_joininfo->jinfo_restrictinfo = restrict_info;
|
||||||
new_joininfo->mergejoinable = mergejoinable;
|
new_joininfo->mergejoinable = mergejoinable;
|
||||||
new_joininfo->hashjoinable = hashjoinable;
|
new_joininfo->hashjoinable = hashjoinable;
|
||||||
new_joininfo->inactive = false;
|
new_joininfo->inactive = false;
|
||||||
|
@ -560,16 +556,16 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
|
||||||
|
|
||||||
if (other_joininfo)
|
if (other_joininfo)
|
||||||
{
|
{
|
||||||
other_joininfo->jinfoclauseinfo =
|
other_joininfo->jinfo_restrictinfo =
|
||||||
(List *) LispUnion(clause_info,
|
(List *) LispUnion(restrict_info,
|
||||||
other_joininfo->jinfoclauseinfo);
|
other_joininfo->jinfo_restrictinfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
JoinInfo *new_joininfo = makeNode(JoinInfo);
|
JoinInfo *new_joininfo = makeNode(JoinInfo);
|
||||||
|
|
||||||
new_joininfo->otherrels = new_relids;
|
new_joininfo->otherrels = new_relids;
|
||||||
new_joininfo->jinfoclauseinfo = clause_info;
|
new_joininfo->jinfo_restrictinfo = restrict_info;
|
||||||
new_joininfo->mergejoinable = mergejoinable;
|
new_joininfo->mergejoinable = mergejoinable;
|
||||||
new_joininfo->hashjoinable = hashjoinable;
|
new_joininfo->hashjoinable = hashjoinable;
|
||||||
new_joininfo->inactive = false;
|
new_joininfo->inactive = false;
|
||||||
|
@ -695,8 +691,8 @@ geqo_joinrel_size(RelOptInfo * joinrel, RelOptInfo * outer_rel, RelOptInfo * inn
|
||||||
|
|
||||||
temp = (Cost) inner_rel->tuples * (Cost) outer_rel->tuples; /* cartesian product */
|
temp = (Cost) inner_rel->tuples * (Cost) outer_rel->tuples; /* cartesian product */
|
||||||
|
|
||||||
if (joinrel->clauseinfo)
|
if (joinrel->restrictinfo)
|
||||||
temp = temp * product_selec(joinrel->clauseinfo);
|
temp = temp * product_selec(joinrel->restrictinfo);
|
||||||
|
|
||||||
if (temp >= (MAXINT - 1))
|
if (temp >= (MAXINT - 1))
|
||||||
ntuples = ceil(geqo_log((double) temp, (double) GEQO_LOG_BASE));
|
ntuples = ceil(geqo_log((double) temp, (double) GEQO_LOG_BASE));
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: geqo_misc.c,v 1.11 1998/09/01 04:29:19 momjian Exp $
|
* $Id: geqo_misc.c,v 1.12 1999/02/03 20:15:27 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -146,7 +146,7 @@ geqo_print_joinclauses(Query *root, List *clauses)
|
||||||
|
|
||||||
foreach(l, clauses)
|
foreach(l, clauses)
|
||||||
{
|
{
|
||||||
ClauseInfo *c = lfirst(l);
|
RestrictInfo *c = lfirst(l);
|
||||||
|
|
||||||
print_expr((Node *) c->clause, root->rtable);
|
print_expr((Node *) c->clause, root->rtable);
|
||||||
if (lnext(l))
|
if (lnext(l))
|
||||||
|
@ -204,7 +204,7 @@ geqo_print_path(Query *root, Path *path, int indent)
|
||||||
printf("\t");
|
printf("\t");
|
||||||
printf(" clauses=(");
|
printf(" clauses=(");
|
||||||
geqo_print_joinclauses(root,
|
geqo_print_joinclauses(root,
|
||||||
((JoinPath *) path)->pathclauseinfo);
|
((JoinPath *) path)->pathinfo);
|
||||||
printf(")\n");
|
printf(")\n");
|
||||||
|
|
||||||
if (nodeTag(path) == T_MergePath)
|
if (nodeTag(path) == T_MergePath)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.24 1999/02/02 20:30:05 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.25 1999/02/03 20:15:28 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -122,10 +122,10 @@ find_rel_paths(Query *root, List *rels)
|
||||||
rel_index_scan_list = find_index_paths(root,
|
rel_index_scan_list = find_index_paths(root,
|
||||||
rel,
|
rel,
|
||||||
find_relation_indices(root, rel),
|
find_relation_indices(root, rel),
|
||||||
rel->clauseinfo,
|
rel->restrictinfo,
|
||||||
rel->joininfo);
|
rel->joininfo);
|
||||||
|
|
||||||
or_index_scan_list = create_or_index_paths(root, rel, rel->clauseinfo);
|
or_index_scan_list = create_or_index_paths(root, rel, rel->restrictinfo);
|
||||||
|
|
||||||
rel->pathlist = add_pathlist(rel,
|
rel->pathlist = add_pathlist(rel,
|
||||||
sequential_scan_list,
|
sequential_scan_list,
|
||||||
|
@ -145,7 +145,7 @@ find_rel_paths(Query *root, List *rels)
|
||||||
* if there is a qualification of sequential scan the selec. value
|
* if there is a qualification of sequential scan the selec. value
|
||||||
* is not set -- so set it explicitly -- Sunita
|
* is not set -- so set it explicitly -- Sunita
|
||||||
*/
|
*/
|
||||||
set_rest_selec(root, rel->clauseinfo);
|
set_rest_selec(root, rel->restrictinfo);
|
||||||
rel->size = compute_rel_size(rel);
|
rel->size = compute_rel_size(rel);
|
||||||
rel->width = compute_rel_width(rel);
|
rel->width = compute_rel_width(rel);
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ print_joinclauses(Query *root, List *clauses)
|
||||||
|
|
||||||
foreach(l, clauses)
|
foreach(l, clauses)
|
||||||
{
|
{
|
||||||
ClauseInfo *c = lfirst(l);
|
RestrictInfo *c = lfirst(l);
|
||||||
|
|
||||||
print_expr((Node *) c->clause, root->rtable);
|
print_expr((Node *) c->clause, root->rtable);
|
||||||
if (lnext(l))
|
if (lnext(l))
|
||||||
|
@ -347,8 +347,7 @@ print_path(Query *root, Path *path, int indent)
|
||||||
for (i = 0; i < indent + 1; i++)
|
for (i = 0; i < indent + 1; i++)
|
||||||
printf("\t");
|
printf("\t");
|
||||||
printf(" clauses=(");
|
printf(" clauses=(");
|
||||||
print_joinclauses(root,
|
print_joinclauses(root, ((JoinPath *) path)->pathinfo);
|
||||||
((JoinPath *) path)->pathclauseinfo);
|
|
||||||
printf(")\n");
|
printf(")\n");
|
||||||
|
|
||||||
if (nodeTag(path) == T_MergePath)
|
if (nodeTag(path) == T_MergePath)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.14 1998/11/09 02:49:13 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.15 1999/02/03 20:15:28 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
#include "nodes/primnodes.h"
|
#include "nodes/primnodes.h"
|
||||||
#include "nodes/relation.h"
|
#include "nodes/relation.h"
|
||||||
#include "optimizer/clauses.h"
|
#include "optimizer/clauses.h"
|
||||||
#include "optimizer/clauseinfo.h"
|
#include "optimizer/restrictinfo.h"
|
||||||
#include "optimizer/cost.h"
|
#include "optimizer/cost.h"
|
||||||
#include "optimizer/internal.h"
|
#include "optimizer/internal.h"
|
||||||
#include "optimizer/plancat.h"
|
#include "optimizer/plancat.h"
|
||||||
|
@ -35,7 +35,7 @@ static Cost compute_selec(Query *root, List *clauses, List *or_selectivities);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set_clause_selectivities -
|
* set_clause_selectivities -
|
||||||
* Sets the selectivity field for each of clause in 'clauseinfo-list'
|
* Sets the selectivity field for each of clause in 'restrictinfo-list'
|
||||||
* to 'new-selectivity'. If the selectivity has already been set, reset
|
* to 'new-selectivity'. If the selectivity has already been set, reset
|
||||||
* it only if the new one is better.
|
* it only if the new one is better.
|
||||||
*
|
*
|
||||||
|
@ -43,15 +43,15 @@ static Cost compute_selec(Query *root, List *clauses, List *or_selectivities);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
set_clause_selectivities(List *clauseinfo_list, Cost new_selectivity)
|
set_clause_selectivities(List *restrictinfo_list, Cost new_selectivity)
|
||||||
{
|
{
|
||||||
List *temp;
|
List *temp;
|
||||||
ClauseInfo *clausenode;
|
RestrictInfo *clausenode;
|
||||||
Cost cost_clause;
|
Cost cost_clause;
|
||||||
|
|
||||||
foreach(temp, clauseinfo_list)
|
foreach(temp, restrictinfo_list)
|
||||||
{
|
{
|
||||||
clausenode = (ClauseInfo *) lfirst(temp);
|
clausenode = (RestrictInfo *) lfirst(temp);
|
||||||
cost_clause = clausenode->selectivity;
|
cost_clause = clausenode->selectivity;
|
||||||
if (FLOAT_IS_ZERO(cost_clause) || new_selectivity < cost_clause)
|
if (FLOAT_IS_ZERO(cost_clause) || new_selectivity < cost_clause)
|
||||||
clausenode->selectivity = new_selectivity;
|
clausenode->selectivity = new_selectivity;
|
||||||
|
@ -60,23 +60,23 @@ set_clause_selectivities(List *clauseinfo_list, Cost new_selectivity)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* product_selec -
|
* product_selec -
|
||||||
* Multiplies the selectivities of each clause in 'clauseinfo-list'.
|
* Multiplies the selectivities of each clause in 'restrictinfo-list'.
|
||||||
*
|
*
|
||||||
* Returns a flonum corresponding to the selectivity of 'clauseinfo-list'.
|
* Returns a flonum corresponding to the selectivity of 'restrictinfo-list'.
|
||||||
*/
|
*/
|
||||||
Cost
|
Cost
|
||||||
product_selec(List *clauseinfo_list)
|
product_selec(List *restrictinfo_list)
|
||||||
{
|
{
|
||||||
Cost result = 1.0;
|
Cost result = 1.0;
|
||||||
|
|
||||||
if (clauseinfo_list != NIL)
|
if (restrictinfo_list != NIL)
|
||||||
{
|
{
|
||||||
List *xclausenode = NIL;
|
List *xclausenode = NIL;
|
||||||
Cost temp;
|
Cost temp;
|
||||||
|
|
||||||
foreach(xclausenode, clauseinfo_list)
|
foreach(xclausenode, restrictinfo_list)
|
||||||
{
|
{
|
||||||
temp = ((ClauseInfo *) lfirst(xclausenode))->selectivity;
|
temp = ((RestrictInfo *) lfirst(xclausenode))->selectivity;
|
||||||
result = result * temp;
|
result = result * temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ product_selec(List *clauseinfo_list)
|
||||||
* those clauses that haven't been assigned a selectivity by an index.
|
* those clauses that haven't been assigned a selectivity by an index.
|
||||||
*
|
*
|
||||||
* Returns nothing of interest.
|
* Returns nothing of interest.
|
||||||
* MODIFIES: selectivities of the various rel's clauseinfo
|
* MODIFIES: selectivities of the various rel's restrictinfo
|
||||||
* slots.
|
* slots.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
|
@ -101,28 +101,28 @@ set_rest_relselec(Query *root, List *rel_list)
|
||||||
foreach(x, rel_list)
|
foreach(x, rel_list)
|
||||||
{
|
{
|
||||||
rel = (RelOptInfo *) lfirst(x);
|
rel = (RelOptInfo *) lfirst(x);
|
||||||
set_rest_selec(root, rel->clauseinfo);
|
set_rest_selec(root, rel->restrictinfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set_rest_selec -
|
* set_rest_selec -
|
||||||
* Sets the selectivity fields for those clauses within a single
|
* Sets the selectivity fields for those clauses within a single
|
||||||
* relation's 'clauseinfo-list' that haven't already been set.
|
* relation's 'restrictinfo-list' that haven't already been set.
|
||||||
*
|
*
|
||||||
* Returns nothing of interest.
|
* Returns nothing of interest.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
set_rest_selec(Query *root, List *clauseinfo_list)
|
set_rest_selec(Query *root, List *restrictinfo_list)
|
||||||
{
|
{
|
||||||
List *temp = NIL;
|
List *temp = NIL;
|
||||||
ClauseInfo *clausenode = (ClauseInfo *) NULL;
|
RestrictInfo *clausenode = (RestrictInfo *) NULL;
|
||||||
Cost cost_clause;
|
Cost cost_clause;
|
||||||
|
|
||||||
foreach(temp, clauseinfo_list)
|
foreach(temp, restrictinfo_list)
|
||||||
{
|
{
|
||||||
clausenode = (ClauseInfo *) lfirst(temp);
|
clausenode = (RestrictInfo *) lfirst(temp);
|
||||||
cost_clause = clausenode->selectivity;
|
cost_clause = clausenode->selectivity;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.25 1998/09/01 04:29:30 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.26 1999/02/03 20:15:32 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -365,7 +365,7 @@ compute_rel_size(RelOptInfo * rel)
|
||||||
Cost temp;
|
Cost temp;
|
||||||
int temp1;
|
int temp1;
|
||||||
|
|
||||||
temp = rel->tuples * product_selec(rel->clauseinfo);
|
temp = rel->tuples * product_selec(rel->restrictinfo);
|
||||||
Assert(temp >= 0);
|
Assert(temp >= 0);
|
||||||
if (temp >= (MAXINT - 1))
|
if (temp >= (MAXINT - 1))
|
||||||
temp1 = MAXINT;
|
temp1 = MAXINT;
|
||||||
|
@ -443,7 +443,7 @@ compute_joinrel_size(JoinPath *joinpath)
|
||||||
temp *= ((Path *) joinpath->outerjoinpath)->parent->size;
|
temp *= ((Path *) joinpath->outerjoinpath)->parent->size;
|
||||||
temp *= ((Path *) joinpath->innerjoinpath)->parent->size;
|
temp *= ((Path *) joinpath->innerjoinpath)->parent->size;
|
||||||
|
|
||||||
temp = temp * product_selec(joinpath->pathclauseinfo);
|
temp = temp * product_selec(joinpath->pathinfo);
|
||||||
if (temp >= (MAXINT - 1))
|
if (temp >= (MAXINT - 1))
|
||||||
temp1 = MAXINT;
|
temp1 = MAXINT;
|
||||||
else
|
else
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/hashutils.c,v 1.7 1998/09/01 04:29:32 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/hashutils.c,v 1.8 1999/02/03 20:15:32 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -24,29 +24,29 @@ static HInfo *match_hashop_hashinfo(Oid hashop, List *hashinfo_list);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* group-clauses-by-hashop--
|
* group-clauses-by-hashop--
|
||||||
* If a join clause node in 'clauseinfo-list' is hashjoinable, store
|
* If a join clause node in 'restrictinfo-list' is hashjoinable, store
|
||||||
* it within a hashinfo node containing other clause nodes with the same
|
* it within a hashinfo node containing other clause nodes with the same
|
||||||
* hash operator.
|
* hash operator.
|
||||||
*
|
*
|
||||||
* 'clauseinfo-list' is the list of clauseinfo nodes
|
* 'restrictinfo-list' is the list of restrictinfo nodes
|
||||||
* 'inner-relid' is the relid of the inner join relation
|
* 'inner-relid' is the relid of the inner join relation
|
||||||
*
|
*
|
||||||
* Returns the new list of hashinfo nodes.
|
* Returns the new list of hashinfo nodes.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
group_clauses_by_hashop(List *clauseinfo_list,
|
group_clauses_by_hashop(List *restrictinfo_list,
|
||||||
int inner_relid)
|
int inner_relid)
|
||||||
{
|
{
|
||||||
List *hashinfo_list = NIL;
|
List *hashinfo_list = NIL;
|
||||||
ClauseInfo *clauseinfo = (ClauseInfo *) NULL;
|
RestrictInfo *restrictinfo = (RestrictInfo *) NULL;
|
||||||
List *i = NIL;
|
List *i = NIL;
|
||||||
Oid hashjoinop = 0;
|
Oid hashjoinop = 0;
|
||||||
|
|
||||||
foreach(i, clauseinfo_list)
|
foreach(i, restrictinfo_list)
|
||||||
{
|
{
|
||||||
clauseinfo = (ClauseInfo *) lfirst(i);
|
restrictinfo = (RestrictInfo *) lfirst(i);
|
||||||
hashjoinop = clauseinfo->hashjoinoperator;
|
hashjoinop = restrictinfo->hashjoinoperator;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new hashinfo node and add it to 'hashinfo-list' if one
|
* Create a new hashinfo node and add it to 'hashinfo-list' if one
|
||||||
|
@ -55,7 +55,7 @@ group_clauses_by_hashop(List *clauseinfo_list,
|
||||||
if (hashjoinop)
|
if (hashjoinop)
|
||||||
{
|
{
|
||||||
HInfo *xhashinfo = (HInfo *) NULL;
|
HInfo *xhashinfo = (HInfo *) NULL;
|
||||||
Expr *clause = clauseinfo->clause;
|
Expr *clause = restrictinfo->clause;
|
||||||
Var *leftop = get_leftop(clause);
|
Var *leftop = get_leftop(clause);
|
||||||
Var *rightop = get_rightop(clause);
|
Var *rightop = get_rightop(clause);
|
||||||
JoinKey *keys = (JoinKey *) NULL;
|
JoinKey *keys = (JoinKey *) NULL;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.35 1998/09/21 15:41:26 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.36 1999/02/03 20:15:32 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
#include "nodes/pg_list.h"
|
#include "nodes/pg_list.h"
|
||||||
#include "nodes/relation.h"
|
#include "nodes/relation.h"
|
||||||
#include "optimizer/clauses.h"
|
#include "optimizer/clauses.h"
|
||||||
#include "optimizer/clauseinfo.h"
|
#include "optimizer/restrictinfo.h"
|
||||||
#include "optimizer/cost.h"
|
#include "optimizer/cost.h"
|
||||||
#include "optimizer/internal.h"
|
#include "optimizer/internal.h"
|
||||||
#include "optimizer/keys.h"
|
#include "optimizer/keys.h"
|
||||||
|
@ -46,25 +46,25 @@
|
||||||
|
|
||||||
|
|
||||||
static void match_index_orclauses(RelOptInfo * rel, RelOptInfo * index, int indexkey,
|
static void match_index_orclauses(RelOptInfo * rel, RelOptInfo * index, int indexkey,
|
||||||
int xclass, List *clauseinfo_list);
|
int xclass, List *restrictinfo_list);
|
||||||
static bool match_index_to_operand(int indexkey, Expr *operand,
|
static bool match_index_to_operand(int indexkey, Expr *operand,
|
||||||
RelOptInfo * rel, RelOptInfo * index);
|
RelOptInfo * rel, RelOptInfo * index);
|
||||||
static List *match_index_orclause(RelOptInfo * rel, RelOptInfo * index, int indexkey,
|
static List *match_index_orclause(RelOptInfo * rel, RelOptInfo * index, int indexkey,
|
||||||
int xclass, List *or_clauses, List *other_matching_indices);
|
int xclass, List *or_clauses, List *other_matching_indices);
|
||||||
static List *group_clauses_by_indexkey(RelOptInfo * rel, RelOptInfo * index,
|
static List *group_clauses_by_indexkey(RelOptInfo * rel, RelOptInfo * index,
|
||||||
int *indexkeys, Oid *classes, List *clauseinfo_list);
|
int *indexkeys, Oid *classes, List *restrictinfo_list);
|
||||||
static List *group_clauses_by_ikey_for_joins(RelOptInfo * rel, RelOptInfo * index,
|
static List *group_clauses_by_ikey_for_joins(RelOptInfo * rel, RelOptInfo * index,
|
||||||
int *indexkeys, Oid *classes, List *join_cinfo_list, List *restr_cinfo_list);
|
int *indexkeys, Oid *classes, List *join_cinfo_list, List *restr_cinfo_list);
|
||||||
static ClauseInfo *match_clause_to_indexkey(RelOptInfo * rel, RelOptInfo * index, int indexkey,
|
static RestrictInfo *match_clause_to_indexkey(RelOptInfo * rel, RelOptInfo * index, int indexkey,
|
||||||
int xclass, ClauseInfo * clauseInfo, bool join);
|
int xclass, RestrictInfo * clauseInfo, bool join);
|
||||||
static bool pred_test(List *predicate_list, List *clauseinfo_list,
|
static bool pred_test(List *predicate_list, List *restrictinfo_list,
|
||||||
List *joininfo_list);
|
List *joininfo_list);
|
||||||
static bool one_pred_test(Expr *predicate, List *clauseinfo_list);
|
static bool one_pred_test(Expr *predicate, List *restrictinfo_list);
|
||||||
static bool one_pred_clause_expr_test(Expr *predicate, Node *clause);
|
static bool one_pred_clause_expr_test(Expr *predicate, Node *clause);
|
||||||
static bool one_pred_clause_test(Expr *predicate, Node *clause);
|
static bool one_pred_clause_test(Expr *predicate, Node *clause);
|
||||||
static bool clause_pred_clause_test(Expr *predicate, Node *clause);
|
static bool clause_pred_clause_test(Expr *predicate, Node *clause);
|
||||||
static List *indexable_joinclauses(RelOptInfo * rel, RelOptInfo * index,
|
static List *indexable_joinclauses(RelOptInfo * rel, RelOptInfo * index,
|
||||||
List *joininfo_list, List *clauseinfo_list);
|
List *joininfo_list, List *restrictinfo_list);
|
||||||
static List *index_innerjoin(Query *root, RelOptInfo * rel,
|
static List *index_innerjoin(Query *root, RelOptInfo * rel,
|
||||||
List *clausegroup_list, RelOptInfo * index);
|
List *clausegroup_list, RelOptInfo * index);
|
||||||
static List *create_index_paths(Query *root, RelOptInfo * rel, RelOptInfo * index,
|
static List *create_index_paths(Query *root, RelOptInfo * rel, RelOptInfo * index,
|
||||||
|
@ -90,7 +90,7 @@ static bool function_index_operand(Expr *funcOpnd, RelOptInfo * rel, RelOptInfo
|
||||||
*
|
*
|
||||||
* 'rel' is the relation entry to which these index paths correspond
|
* 'rel' is the relation entry to which these index paths correspond
|
||||||
* 'indices' is a list of possible index paths
|
* 'indices' is a list of possible index paths
|
||||||
* 'clauseinfo-list' is a list of restriction clauseinfo nodes for 'rel'
|
* 'restrictinfo-list' is a list of restriction restrictinfo nodes for 'rel'
|
||||||
* 'joininfo-list' is a list of joininfo nodes for 'rel'
|
* 'joininfo-list' is a list of joininfo nodes for 'rel'
|
||||||
* 'sortkeys' is a node describing the result sort order (from
|
* 'sortkeys' is a node describing the result sort order (from
|
||||||
* (find_sortkeys))
|
* (find_sortkeys))
|
||||||
|
@ -102,7 +102,7 @@ List *
|
||||||
find_index_paths(Query *root,
|
find_index_paths(Query *root,
|
||||||
RelOptInfo * rel,
|
RelOptInfo * rel,
|
||||||
List *indices,
|
List *indices,
|
||||||
List *clauseinfo_list,
|
List *restrictinfo_list,
|
||||||
List *joininfo_list)
|
List *joininfo_list)
|
||||||
{
|
{
|
||||||
List *scanclausegroups = NIL;
|
List *scanclausegroups = NIL;
|
||||||
|
@ -122,12 +122,12 @@ find_index_paths(Query *root,
|
||||||
* test
|
* test
|
||||||
*/
|
*/
|
||||||
if (index->indpred != NIL)
|
if (index->indpred != NIL)
|
||||||
if (!pred_test(index->indpred, clauseinfo_list, joininfo_list))
|
if (!pred_test(index->indpred, restrictinfo_list, joininfo_list))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1. Try matching the index against subclauses of an 'or' clause.
|
* 1. Try matching the index against subclauses of an 'or' clause.
|
||||||
* The fields of the clauseinfo nodes are marked with lists of the
|
* The fields of the restrictinfo nodes are marked with lists of the
|
||||||
* matching indices. No path are actually created. We currently
|
* matching indices. No path are actually created. We currently
|
||||||
* only look to match the first key. We don't find multi-key
|
* only look to match the first key. We don't find multi-key
|
||||||
* index cases where an AND matches the first key, and the OR
|
* index cases where an AND matches the first key, and the OR
|
||||||
|
@ -137,7 +137,7 @@ find_index_paths(Query *root,
|
||||||
index,
|
index,
|
||||||
index->indexkeys[0],
|
index->indexkeys[0],
|
||||||
index->classlist[0],
|
index->classlist[0],
|
||||||
clauseinfo_list);
|
restrictinfo_list);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 2. If the keys of this index match any of the available
|
* 2. If the keys of this index match any of the available
|
||||||
|
@ -148,7 +148,7 @@ find_index_paths(Query *root,
|
||||||
index,
|
index,
|
||||||
index->indexkeys,
|
index->indexkeys,
|
||||||
index->classlist,
|
index->classlist,
|
||||||
clauseinfo_list);
|
restrictinfo_list);
|
||||||
|
|
||||||
scanpaths = NIL;
|
scanpaths = NIL;
|
||||||
if (scanclausegroups != NIL)
|
if (scanclausegroups != NIL)
|
||||||
|
@ -165,7 +165,7 @@ find_index_paths(Query *root,
|
||||||
* mergejoin, or if the index can possibly be used for scanning
|
* mergejoin, or if the index can possibly be used for scanning
|
||||||
* the inner relation of a nestloop join.
|
* the inner relation of a nestloop join.
|
||||||
*/
|
*/
|
||||||
joinclausegroups = indexable_joinclauses(rel, index, joininfo_list, clauseinfo_list);
|
joinclausegroups = indexable_joinclauses(rel, index, joininfo_list, restrictinfo_list);
|
||||||
joinpaths = NIL;
|
joinpaths = NIL;
|
||||||
|
|
||||||
if (joinclausegroups != NIL)
|
if (joinclausegroups != NIL)
|
||||||
|
@ -206,13 +206,13 @@ find_index_paths(Query *root,
|
||||||
* about the index.
|
* about the index.
|
||||||
*
|
*
|
||||||
* Essentially, this adds 'index' to the list of indices in the
|
* Essentially, this adds 'index' to the list of indices in the
|
||||||
* ClauseInfo field of each of the clauses which it matches.
|
* RestrictInfo field of each of the clauses which it matches.
|
||||||
*
|
*
|
||||||
* 'rel' is the node of the relation on which the index is defined.
|
* 'rel' is the node of the relation on which the index is defined.
|
||||||
* 'index' is the index node.
|
* 'index' is the index node.
|
||||||
* 'indexkey' is the (single) key of the index
|
* 'indexkey' is the (single) key of the index
|
||||||
* 'class' is the class of the operator corresponding to 'indexkey'.
|
* 'class' is the class of the operator corresponding to 'indexkey'.
|
||||||
* 'clauseinfo-list' is the list of available restriction clauses.
|
* 'restrictinfo-list' is the list of available restriction clauses.
|
||||||
*
|
*
|
||||||
* Returns nothing.
|
* Returns nothing.
|
||||||
*
|
*
|
||||||
|
@ -222,15 +222,15 @@ match_index_orclauses(RelOptInfo * rel,
|
||||||
RelOptInfo * index,
|
RelOptInfo * index,
|
||||||
int indexkey,
|
int indexkey,
|
||||||
int xclass,
|
int xclass,
|
||||||
List *clauseinfo_list)
|
List *restrictinfo_list)
|
||||||
{
|
{
|
||||||
ClauseInfo *clauseinfo = (ClauseInfo *) NULL;
|
RestrictInfo *restrictinfo = (RestrictInfo *) NULL;
|
||||||
List *i = NIL;
|
List *i = NIL;
|
||||||
|
|
||||||
foreach(i, clauseinfo_list)
|
foreach(i, restrictinfo_list)
|
||||||
{
|
{
|
||||||
clauseinfo = (ClauseInfo *) lfirst(i);
|
restrictinfo = (RestrictInfo *) lfirst(i);
|
||||||
if (valid_or_clause(clauseinfo))
|
if (valid_or_clause(restrictinfo))
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -238,11 +238,11 @@ match_index_orclauses(RelOptInfo * rel,
|
||||||
* each of its subclauses. The list is generated by adding
|
* each of its subclauses. The list is generated by adding
|
||||||
* 'index' to the existing list where appropriate.
|
* 'index' to the existing list where appropriate.
|
||||||
*/
|
*/
|
||||||
clauseinfo->indexids =
|
restrictinfo->indexids =
|
||||||
match_index_orclause(rel, index, indexkey,
|
match_index_orclause(rel, index, indexkey,
|
||||||
xclass,
|
xclass,
|
||||||
clauseinfo->clause->args,
|
restrictinfo->clause->args,
|
||||||
clauseinfo->indexids);
|
restrictinfo->indexids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,15 +392,15 @@ group_clauses_by_indexkey(RelOptInfo * rel,
|
||||||
RelOptInfo * index,
|
RelOptInfo * index,
|
||||||
int *indexkeys,
|
int *indexkeys,
|
||||||
Oid *classes,
|
Oid *classes,
|
||||||
List *clauseinfo_list)
|
List *restrictinfo_list)
|
||||||
{
|
{
|
||||||
List *curCinfo = NIL;
|
List *curCinfo = NIL;
|
||||||
ClauseInfo *matched_clause = (ClauseInfo *) NULL;
|
RestrictInfo *matched_clause = (RestrictInfo *) NULL;
|
||||||
List *clausegroup = NIL;
|
List *clausegroup = NIL;
|
||||||
int curIndxKey;
|
int curIndxKey;
|
||||||
Oid curClass;
|
Oid curClass;
|
||||||
|
|
||||||
if (clauseinfo_list == NIL || indexkeys[0] == 0)
|
if (restrictinfo_list == NIL || indexkeys[0] == 0)
|
||||||
return NIL;
|
return NIL;
|
||||||
|
|
||||||
do
|
do
|
||||||
|
@ -410,9 +410,9 @@ group_clauses_by_indexkey(RelOptInfo * rel,
|
||||||
curIndxKey = indexkeys[0];
|
curIndxKey = indexkeys[0];
|
||||||
curClass = classes[0];
|
curClass = classes[0];
|
||||||
|
|
||||||
foreach(curCinfo, clauseinfo_list)
|
foreach(curCinfo, restrictinfo_list)
|
||||||
{
|
{
|
||||||
ClauseInfo *temp = (ClauseInfo *) lfirst(curCinfo);
|
RestrictInfo *temp = (RestrictInfo *) lfirst(curCinfo);
|
||||||
|
|
||||||
matched_clause = match_clause_to_indexkey(rel,
|
matched_clause = match_clause_to_indexkey(rel,
|
||||||
index,
|
index,
|
||||||
|
@ -458,7 +458,7 @@ group_clauses_by_ikey_for_joins(RelOptInfo * rel,
|
||||||
List *restr_cinfo_list)
|
List *restr_cinfo_list)
|
||||||
{
|
{
|
||||||
List *curCinfo = NIL;
|
List *curCinfo = NIL;
|
||||||
ClauseInfo *matched_clause = (ClauseInfo *) NULL;
|
RestrictInfo *matched_clause = (RestrictInfo *) NULL;
|
||||||
List *clausegroup = NIL;
|
List *clausegroup = NIL;
|
||||||
int curIndxKey;
|
int curIndxKey;
|
||||||
Oid curClass;
|
Oid curClass;
|
||||||
|
@ -476,7 +476,7 @@ group_clauses_by_ikey_for_joins(RelOptInfo * rel,
|
||||||
|
|
||||||
foreach(curCinfo, join_cinfo_list)
|
foreach(curCinfo, join_cinfo_list)
|
||||||
{
|
{
|
||||||
ClauseInfo *temp = (ClauseInfo *) lfirst(curCinfo);
|
RestrictInfo *temp = (RestrictInfo *) lfirst(curCinfo);
|
||||||
|
|
||||||
matched_clause = match_clause_to_indexkey(rel,
|
matched_clause = match_clause_to_indexkey(rel,
|
||||||
index,
|
index,
|
||||||
|
@ -492,7 +492,7 @@ group_clauses_by_ikey_for_joins(RelOptInfo * rel,
|
||||||
}
|
}
|
||||||
foreach(curCinfo, restr_cinfo_list)
|
foreach(curCinfo, restr_cinfo_list)
|
||||||
{
|
{
|
||||||
ClauseInfo *temp = (ClauseInfo *) lfirst(curCinfo);
|
RestrictInfo *temp = (RestrictInfo *) lfirst(curCinfo);
|
||||||
|
|
||||||
matched_clause = match_clause_to_indexkey(rel,
|
matched_clause = match_clause_to_indexkey(rel,
|
||||||
index,
|
index,
|
||||||
|
@ -565,18 +565,18 @@ group_clauses_by_ikey_for_joins(RelOptInfo * rel,
|
||||||
*
|
*
|
||||||
* If the clause being matched is a join clause, then 'join' is t.
|
* If the clause being matched is a join clause, then 'join' is t.
|
||||||
*
|
*
|
||||||
* Returns a single clauseinfo node corresponding to the matching
|
* Returns a single restrictinfo node corresponding to the matching
|
||||||
* clause.
|
* clause.
|
||||||
*
|
*
|
||||||
* NOTE: returns nil if clause is an or_clause.
|
* NOTE: returns nil if clause is an or_clause.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static ClauseInfo *
|
static RestrictInfo *
|
||||||
match_clause_to_indexkey(RelOptInfo * rel,
|
match_clause_to_indexkey(RelOptInfo * rel,
|
||||||
RelOptInfo * index,
|
RelOptInfo * index,
|
||||||
int indexkey,
|
int indexkey,
|
||||||
int xclass,
|
int xclass,
|
||||||
ClauseInfo * clauseInfo,
|
RestrictInfo * clauseInfo,
|
||||||
bool join)
|
bool join)
|
||||||
{
|
{
|
||||||
Expr *clause = clauseInfo->clause;
|
Expr *clause = clauseInfo->clause;
|
||||||
|
@ -588,7 +588,7 @@ match_clause_to_indexkey(RelOptInfo * rel,
|
||||||
|
|
||||||
if (or_clause((Node *) clause) ||
|
if (or_clause((Node *) clause) ||
|
||||||
not_clause((Node *) clause) || single_node((Node *) clause))
|
not_clause((Node *) clause) || single_node((Node *) clause))
|
||||||
return (ClauseInfo *) NULL;
|
return (RestrictInfo *) NULL;
|
||||||
|
|
||||||
leftop = get_leftop(clause);
|
leftop = get_leftop(clause);
|
||||||
rightop = get_rightop(clause);
|
rightop = get_rightop(clause);
|
||||||
|
@ -778,7 +778,7 @@ match_clause_to_indexkey(RelOptInfo * rel,
|
||||||
* pred_test--
|
* pred_test--
|
||||||
* Does the "predicate inclusion test" for partial indexes.
|
* Does the "predicate inclusion test" for partial indexes.
|
||||||
*
|
*
|
||||||
* Recursively checks whether the clauses in clauseinfo_list imply
|
* Recursively checks whether the clauses in restrictinfo_list imply
|
||||||
* that the given predicate is true.
|
* that the given predicate is true.
|
||||||
*
|
*
|
||||||
* This routine (together with the routines it calls) iterates over
|
* This routine (together with the routines it calls) iterates over
|
||||||
|
@ -789,7 +789,7 @@ match_clause_to_indexkey(RelOptInfo * rel,
|
||||||
* successfully cnfify()-ed). --Nels, Jan '93
|
* successfully cnfify()-ed). --Nels, Jan '93
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
pred_test(List *predicate_list, List *clauseinfo_list, List *joininfo_list)
|
pred_test(List *predicate_list, List *restrictinfo_list, List *joininfo_list)
|
||||||
{
|
{
|
||||||
List *pred,
|
List *pred,
|
||||||
*items,
|
*items,
|
||||||
|
@ -802,12 +802,12 @@ pred_test(List *predicate_list, List *clauseinfo_list, List *joininfo_list)
|
||||||
* an index on c.d), then we could use that equivalence class info
|
* an index on c.d), then we could use that equivalence class info
|
||||||
* here with joininfo_list to do more complete tests for the usability
|
* here with joininfo_list to do more complete tests for the usability
|
||||||
* of a partial index. For now, the test only uses restriction
|
* of a partial index. For now, the test only uses restriction
|
||||||
* clauses (those in clauseinfo_list). --Nels, Dec '92
|
* clauses (those in restrictinfo_list). --Nels, Dec '92
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (predicate_list == NULL)
|
if (predicate_list == NULL)
|
||||||
return true; /* no predicate: the index is usable */
|
return true; /* no predicate: the index is usable */
|
||||||
if (clauseinfo_list == NULL)
|
if (restrictinfo_list == NULL)
|
||||||
return false; /* no restriction clauses: the test must
|
return false; /* no restriction clauses: the test must
|
||||||
* fail */
|
* fail */
|
||||||
|
|
||||||
|
@ -823,11 +823,11 @@ pred_test(List *predicate_list, List *clauseinfo_list, List *joininfo_list)
|
||||||
items = ((Expr *) lfirst(pred))->args;
|
items = ((Expr *) lfirst(pred))->args;
|
||||||
foreach(item, items)
|
foreach(item, items)
|
||||||
{
|
{
|
||||||
if (!one_pred_test(lfirst(item), clauseinfo_list))
|
if (!one_pred_test(lfirst(item), restrictinfo_list))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!one_pred_test(lfirst(pred), clauseinfo_list))
|
else if (!one_pred_test(lfirst(pred), restrictinfo_list))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -840,17 +840,17 @@ pred_test(List *predicate_list, List *clauseinfo_list, List *joininfo_list)
|
||||||
* expression.
|
* expression.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
one_pred_test(Expr *predicate, List *clauseinfo_list)
|
one_pred_test(Expr *predicate, List *restrictinfo_list)
|
||||||
{
|
{
|
||||||
ClauseInfo *clauseinfo;
|
RestrictInfo *restrictinfo;
|
||||||
List *item;
|
List *item;
|
||||||
|
|
||||||
Assert(predicate != NULL);
|
Assert(predicate != NULL);
|
||||||
foreach(item, clauseinfo_list)
|
foreach(item, restrictinfo_list)
|
||||||
{
|
{
|
||||||
clauseinfo = (ClauseInfo *) lfirst(item);
|
restrictinfo = (RestrictInfo *) lfirst(item);
|
||||||
/* if any clause implies the predicate, return true */
|
/* if any clause implies the predicate, return true */
|
||||||
if (one_pred_clause_expr_test(predicate, (Node *) clauseinfo->clause))
|
if (one_pred_clause_expr_test(predicate, (Node *) restrictinfo->clause))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1181,14 +1181,14 @@ clause_pred_clause_test(Expr *predicate, Node *clause)
|
||||||
*
|
*
|
||||||
* Returns a list of these clause groups.
|
* Returns a list of these clause groups.
|
||||||
*
|
*
|
||||||
* Added: clauseinfo_list - list of restriction ClauseInfos. It's to
|
* Added: restrictinfo_list - list of restriction RestrictInfos. It's to
|
||||||
* support multi-column indices in joins and for cases
|
* support multi-column indices in joins and for cases
|
||||||
* when a key is in both join & restriction clauses. - vadim 03/18/97
|
* when a key is in both join & restriction clauses. - vadim 03/18/97
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static List *
|
static List *
|
||||||
indexable_joinclauses(RelOptInfo * rel, RelOptInfo * index,
|
indexable_joinclauses(RelOptInfo * rel, RelOptInfo * index,
|
||||||
List *joininfo_list, List *clauseinfo_list)
|
List *joininfo_list, List *restrictinfo_list)
|
||||||
{
|
{
|
||||||
JoinInfo *joininfo = (JoinInfo *) NULL;
|
JoinInfo *joininfo = (JoinInfo *) NULL;
|
||||||
List *cg_list = NIL;
|
List *cg_list = NIL;
|
||||||
|
@ -1199,21 +1199,21 @@ indexable_joinclauses(RelOptInfo * rel, RelOptInfo * index,
|
||||||
{
|
{
|
||||||
joininfo = (JoinInfo *) lfirst(i);
|
joininfo = (JoinInfo *) lfirst(i);
|
||||||
|
|
||||||
if (joininfo->jinfoclauseinfo == NIL)
|
if (joininfo->jinfo_restrictinfo == NIL)
|
||||||
continue;
|
continue;
|
||||||
clausegroups =
|
clausegroups =
|
||||||
group_clauses_by_ikey_for_joins(rel,
|
group_clauses_by_ikey_for_joins(rel,
|
||||||
index,
|
index,
|
||||||
index->indexkeys,
|
index->indexkeys,
|
||||||
index->classlist,
|
index->classlist,
|
||||||
joininfo->jinfoclauseinfo,
|
joininfo->jinfo_restrictinfo,
|
||||||
clauseinfo_list);
|
restrictinfo_list);
|
||||||
|
|
||||||
if (clausegroups != NIL)
|
if (clausegroups != NIL)
|
||||||
{
|
{
|
||||||
List *clauses = lfirst(clausegroups);
|
List *clauses = lfirst(clausegroups);
|
||||||
|
|
||||||
((ClauseInfo *) lfirst(clauses))->cinfojoinid =
|
((RestrictInfo *) lfirst(clauses))->cinfojoinid =
|
||||||
joininfo->otherrels;
|
joininfo->otherrels;
|
||||||
}
|
}
|
||||||
cg_list = nconc(cg_list, clausegroups);
|
cg_list = nconc(cg_list, clausegroups);
|
||||||
|
@ -1239,7 +1239,7 @@ extract_restrict_clauses(List *clausegroup)
|
||||||
|
|
||||||
foreach(l, clausegroup)
|
foreach(l, clausegroup)
|
||||||
{
|
{
|
||||||
ClauseInfo *cinfo = lfirst(l);
|
RestrictInfo *cinfo = lfirst(l);
|
||||||
|
|
||||||
if (!is_joinable((Node *) cinfo->clause))
|
if (!is_joinable((Node *) cinfo->clause))
|
||||||
restrict_cls = lappend(restrict_cls, cinfo);
|
restrict_cls = lappend(restrict_cls, cinfo);
|
||||||
|
@ -1254,7 +1254,7 @@ extract_restrict_clauses(List *clausegroup)
|
||||||
* Creates index path nodes corresponding to paths to be used as inner
|
* Creates index path nodes corresponding to paths to be used as inner
|
||||||
* relations in nestloop joins.
|
* relations in nestloop joins.
|
||||||
*
|
*
|
||||||
* 'clausegroup-list' is a list of list of clauseinfo nodes which can use
|
* 'clausegroup-list' is a list of list of restrictinfo nodes which can use
|
||||||
* 'index' on their inner relation.
|
* 'index' on their inner relation.
|
||||||
*
|
*
|
||||||
* Returns a list of index pathnodes.
|
* Returns a list of index pathnodes.
|
||||||
|
@ -1304,7 +1304,7 @@ index_innerjoin(Query *root, RelOptInfo * rel, List *clausegroup_list,
|
||||||
pathnode->indexkeys = index->indexkeys;
|
pathnode->indexkeys = index->indexkeys;
|
||||||
pathnode->indexqual = clausegroup;
|
pathnode->indexqual = clausegroup;
|
||||||
|
|
||||||
pathnode->path.joinid = ((ClauseInfo *) lfirst(clausegroup))->cinfojoinid;
|
pathnode->path.joinid = ((RestrictInfo *) lfirst(clausegroup))->cinfojoinid;
|
||||||
|
|
||||||
pathnode->path.path_cost =
|
pathnode->path.path_cost =
|
||||||
cost_index((Oid) lfirsti(index->relids),
|
cost_index((Oid) lfirsti(index->relids),
|
||||||
|
@ -1317,11 +1317,11 @@ index_innerjoin(Query *root, RelOptInfo * rel, List *clausegroup_list,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* copy clauseinfo list into path for expensive function
|
* copy restrictinfo list into path for expensive function
|
||||||
* processing -- JMH, 7/7/92
|
* processing -- JMH, 7/7/92
|
||||||
*/
|
*/
|
||||||
pathnode->path.locclauseinfo =
|
pathnode->path.loc_restrictinfo =
|
||||||
set_difference(copyObject((Node *) rel->clauseinfo),
|
set_difference(copyObject((Node *) rel->restrictinfo),
|
||||||
clausegroup);
|
clausegroup);
|
||||||
|
|
||||||
#if 0 /* fix xfunc */
|
#if 0 /* fix xfunc */
|
||||||
|
@ -1343,7 +1343,7 @@ index_innerjoin(Query *root, RelOptInfo * rel, List *clausegroup_list,
|
||||||
* (restriction or join) that can be used in conjunction with an index.
|
* (restriction or join) that can be used in conjunction with an index.
|
||||||
*
|
*
|
||||||
* 'rel' is the relation for which 'index' is defined
|
* 'rel' is the relation for which 'index' is defined
|
||||||
* 'clausegroup-list' is the list of clause groups (lists of clauseinfo
|
* 'clausegroup-list' is the list of clause groups (lists of restrictinfo
|
||||||
* nodes) grouped by mergejoinorder
|
* nodes) grouped by mergejoinorder
|
||||||
* 'join' is a flag indicating whether or not the clauses are join
|
* 'join' is a flag indicating whether or not the clauses are join
|
||||||
* clauses
|
* clauses
|
||||||
|
@ -1366,7 +1366,7 @@ create_index_paths(Query *root,
|
||||||
|
|
||||||
foreach(i, clausegroup_list)
|
foreach(i, clausegroup_list)
|
||||||
{
|
{
|
||||||
ClauseInfo *clauseinfo;
|
RestrictInfo *restrictinfo;
|
||||||
List *temp_node = NIL;
|
List *temp_node = NIL;
|
||||||
bool temp = true;
|
bool temp = true;
|
||||||
|
|
||||||
|
@ -1374,10 +1374,10 @@ create_index_paths(Query *root,
|
||||||
|
|
||||||
foreach(j, clausegroup)
|
foreach(j, clausegroup)
|
||||||
{
|
{
|
||||||
clauseinfo = (ClauseInfo *) lfirst(j);
|
restrictinfo = (RestrictInfo *) lfirst(j);
|
||||||
if (!(is_joinable((Node *) clauseinfo->clause) &&
|
if (!(is_joinable((Node *) restrictinfo->clause) &&
|
||||||
equal_path_merge_ordering(index->ordering,
|
equal_path_merge_ordering(index->ordering,
|
||||||
clauseinfo->mergejoinorder)))
|
restrictinfo->mergejoinorder)))
|
||||||
temp = false;
|
temp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.10 1998/09/01 04:29:35 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.11 1999/02/03 20:15:33 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -97,14 +97,14 @@ find_all_join_paths(Query *root, List *joinrels)
|
||||||
if (_enable_mergejoin_)
|
if (_enable_mergejoin_)
|
||||||
{
|
{
|
||||||
mergeinfo_list =
|
mergeinfo_list =
|
||||||
group_clauses_by_order(joinrel->clauseinfo,
|
group_clauses_by_order(joinrel->restrictinfo,
|
||||||
lfirsti(innerrel->relids));
|
lfirsti(innerrel->relids));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_enable_hashjoin_)
|
if (_enable_hashjoin_)
|
||||||
{
|
{
|
||||||
hashinfo_list =
|
hashinfo_list =
|
||||||
group_clauses_by_hashop(joinrel->clauseinfo,
|
group_clauses_by_hashop(joinrel->restrictinfo,
|
||||||
lfirsti(innerrel->relids));
|
lfirsti(innerrel->relids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.15 1998/09/01 04:29:37 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.16 1999/02/03 20:15:33 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -224,7 +224,7 @@ init_join_rel(RelOptInfo * outer_rel, RelOptInfo * inner_rel, JoinInfo * joininf
|
||||||
joinrel->classlist = NULL;
|
joinrel->classlist = NULL;
|
||||||
joinrel->relam = InvalidOid;
|
joinrel->relam = InvalidOid;
|
||||||
joinrel->ordering = NULL;
|
joinrel->ordering = NULL;
|
||||||
joinrel->clauseinfo = NIL;
|
joinrel->restrictinfo = NIL;
|
||||||
joinrel->joininfo = NULL;
|
joinrel->joininfo = NULL;
|
||||||
joinrel->innerjoin = NIL;
|
joinrel->innerjoin = NIL;
|
||||||
joinrel->superrels = NIL;
|
joinrel->superrels = NIL;
|
||||||
|
@ -238,7 +238,7 @@ init_join_rel(RelOptInfo * outer_rel, RelOptInfo * inner_rel, JoinInfo * joininf
|
||||||
|
|
||||||
if (joininfo)
|
if (joininfo)
|
||||||
{
|
{
|
||||||
joinrel->clauseinfo = joininfo->jinfoclauseinfo;
|
joinrel->restrictinfo = joininfo->jinfo_restrictinfo;
|
||||||
if (BushyPlanFlag)
|
if (BushyPlanFlag)
|
||||||
joininfo->inactive = true;
|
joininfo->inactive = true;
|
||||||
}
|
}
|
||||||
|
@ -346,22 +346,18 @@ new_joininfo_list(List *joininfo_list, List *join_relids)
|
||||||
current_joininfo_list);
|
current_joininfo_list);
|
||||||
if (other_joininfo)
|
if (other_joininfo)
|
||||||
{
|
{
|
||||||
other_joininfo->jinfoclauseinfo =
|
other_joininfo->jinfo_restrictinfo =
|
||||||
(List *) LispUnion(joininfo->jinfoclauseinfo,
|
(List *) LispUnion(joininfo->jinfo_restrictinfo,
|
||||||
other_joininfo->jinfoclauseinfo);
|
other_joininfo->jinfo_restrictinfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
other_joininfo = makeNode(JoinInfo);
|
other_joininfo = makeNode(JoinInfo);
|
||||||
|
|
||||||
other_joininfo->otherrels =
|
other_joininfo->otherrels = joininfo->otherrels;
|
||||||
joininfo->otherrels;
|
other_joininfo->jinfo_restrictinfo = joininfo->jinfo_restrictinfo;
|
||||||
other_joininfo->jinfoclauseinfo =
|
other_joininfo->mergejoinable = joininfo->mergejoinable;
|
||||||
joininfo->jinfoclauseinfo;
|
other_joininfo->hashjoinable = joininfo->hashjoinable;
|
||||||
other_joininfo->mergejoinable =
|
|
||||||
joininfo->mergejoinable;
|
|
||||||
other_joininfo->hashjoinable =
|
|
||||||
joininfo->hashjoinable;
|
|
||||||
other_joininfo->inactive = false;
|
other_joininfo->inactive = false;
|
||||||
|
|
||||||
current_joininfo_list = lcons(other_joininfo,
|
current_joininfo_list = lcons(other_joininfo,
|
||||||
|
@ -412,7 +408,7 @@ add_new_joininfos(Query *root, List *joinrels, List *outerrels)
|
||||||
{
|
{
|
||||||
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
|
JoinInfo *joininfo = (JoinInfo *) lfirst(xjoininfo);
|
||||||
List *other_rels = joininfo->otherrels;
|
List *other_rels = joininfo->otherrels;
|
||||||
List *clause_info = joininfo->jinfoclauseinfo;
|
List *restrict_info = joininfo->jinfo_restrictinfo;
|
||||||
bool mergejoinable = joininfo->mergejoinable;
|
bool mergejoinable = joininfo->mergejoinable;
|
||||||
bool hashjoinable = joininfo->hashjoinable;
|
bool hashjoinable = joininfo->hashjoinable;
|
||||||
|
|
||||||
|
@ -425,7 +421,7 @@ add_new_joininfos(Query *root, List *joinrels, List *outerrels)
|
||||||
JoinInfo *new_joininfo = makeNode(JoinInfo);
|
JoinInfo *new_joininfo = makeNode(JoinInfo);
|
||||||
|
|
||||||
new_joininfo->otherrels = joinrel->relids;
|
new_joininfo->otherrels = joinrel->relids;
|
||||||
new_joininfo->jinfoclauseinfo = clause_info;
|
new_joininfo->jinfo_restrictinfo = restrict_info;
|
||||||
new_joininfo->mergejoinable = mergejoinable;
|
new_joininfo->mergejoinable = mergejoinable;
|
||||||
new_joininfo->hashjoinable = hashjoinable;
|
new_joininfo->hashjoinable = hashjoinable;
|
||||||
new_joininfo->inactive = false;
|
new_joininfo->inactive = false;
|
||||||
|
@ -445,16 +441,16 @@ add_new_joininfos(Query *root, List *joinrels, List *outerrels)
|
||||||
|
|
||||||
if (other_joininfo)
|
if (other_joininfo)
|
||||||
{
|
{
|
||||||
other_joininfo->jinfoclauseinfo =
|
other_joininfo->jinfo_restrictinfo =
|
||||||
(List *) LispUnion(clause_info,
|
(List *) LispUnion(restrict_info,
|
||||||
other_joininfo->jinfoclauseinfo);
|
other_joininfo->jinfo_restrictinfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
JoinInfo *new_joininfo = makeNode(JoinInfo);
|
JoinInfo *new_joininfo = makeNode(JoinInfo);
|
||||||
|
|
||||||
new_joininfo->otherrels = new_relids;
|
new_joininfo->otherrels = new_relids;
|
||||||
new_joininfo->jinfoclauseinfo = clause_info;
|
new_joininfo->jinfo_restrictinfo = restrict_info;
|
||||||
new_joininfo->mergejoinable = mergejoinable;
|
new_joininfo->mergejoinable = mergejoinable;
|
||||||
new_joininfo->hashjoinable = hashjoinable;
|
new_joininfo->hashjoinable = hashjoinable;
|
||||||
new_joininfo->inactive = false;
|
new_joininfo->inactive = false;
|
||||||
|
@ -583,7 +579,7 @@ set_joinrel_size(RelOptInfo * joinrel, RelOptInfo * outer_rel, RelOptInfo * inne
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
selec = product_selec(jinfo->jinfoclauseinfo);
|
selec = product_selec(jinfo->jinfo_restrictinfo);
|
||||||
/* ntuples = Min(outer_rel->tuples,inner_rel->tuples) * selec; */
|
/* ntuples = Min(outer_rel->tuples,inner_rel->tuples) * selec; */
|
||||||
ntuples = outer_rel->tuples * inner_rel->tuples * selec;
|
ntuples = outer_rel->tuples * inner_rel->tuples * selec;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.9 1998/09/01 04:29:40 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.10 1999/02/03 20:15:33 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -23,27 +23,27 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* group-clauses-by-order--
|
* group-clauses-by-order--
|
||||||
* If a join clause node in 'clauseinfo-list' is mergejoinable, store
|
* If a join clause node in 'restrictinfo-list' is mergejoinable, store
|
||||||
* it within a mergeinfo node containing other clause nodes with the same
|
* it within a mergeinfo node containing other clause nodes with the same
|
||||||
* mergejoin ordering.
|
* mergejoin ordering.
|
||||||
*
|
*
|
||||||
* 'clauseinfo-list' is the list of clauseinfo nodes
|
* 'restrictinfo-list' is the list of restrictinfo nodes
|
||||||
* 'inner-relid' is the relid of the inner join relation
|
* 'inner-relid' is the relid of the inner join relation
|
||||||
*
|
*
|
||||||
* Returns the new list of mergeinfo nodes.
|
* Returns the new list of mergeinfo nodes.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
group_clauses_by_order(List *clauseinfo_list,
|
group_clauses_by_order(List *restrictinfo_list,
|
||||||
int inner_relid)
|
int inner_relid)
|
||||||
{
|
{
|
||||||
List *mergeinfo_list = NIL;
|
List *mergeinfo_list = NIL;
|
||||||
List *xclauseinfo = NIL;
|
List *xrestrictinfo = NIL;
|
||||||
|
|
||||||
foreach(xclauseinfo, clauseinfo_list)
|
foreach(xrestrictinfo, restrictinfo_list)
|
||||||
{
|
{
|
||||||
ClauseInfo *clauseinfo = (ClauseInfo *) lfirst(xclauseinfo);
|
RestrictInfo *restrictinfo = (RestrictInfo *) lfirst(xrestrictinfo);
|
||||||
MergeOrder *merge_ordering = clauseinfo->mergejoinorder;
|
MergeOrder *merge_ordering = restrictinfo->mergejoinorder;
|
||||||
|
|
||||||
if (merge_ordering)
|
if (merge_ordering)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ group_clauses_by_order(List *clauseinfo_list,
|
||||||
*/
|
*/
|
||||||
PathOrder p_ordering;
|
PathOrder p_ordering;
|
||||||
MInfo *xmergeinfo;
|
MInfo *xmergeinfo;
|
||||||
Expr *clause = clauseinfo->clause;
|
Expr *clause = restrictinfo->clause;
|
||||||
Var *leftop = get_leftop(clause);
|
Var *leftop = get_leftop(clause);
|
||||||
Var *rightop = get_rightop(clause);
|
Var *rightop = get_rightop(clause);
|
||||||
JoinKey *keys;
|
JoinKey *keys;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.12 1998/09/21 15:41:27 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.13 1999/02/03 20:15:33 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "optimizer/internal.h"
|
#include "optimizer/internal.h"
|
||||||
#include "optimizer/clauses.h"
|
#include "optimizer/clauses.h"
|
||||||
#include "optimizer/clauseinfo.h"
|
#include "optimizer/restrictinfo.h"
|
||||||
#include "optimizer/paths.h"
|
#include "optimizer/paths.h"
|
||||||
#include "optimizer/cost.h"
|
#include "optimizer/cost.h"
|
||||||
#include "optimizer/plancat.h"
|
#include "optimizer/plancat.h"
|
||||||
|
@ -58,7 +58,7 @@ create_or_index_paths(Query *root,
|
||||||
|
|
||||||
foreach(clist, clauses)
|
foreach(clist, clauses)
|
||||||
{
|
{
|
||||||
ClauseInfo *clausenode = (ClauseInfo *) (lfirst(clist));
|
RestrictInfo *clausenode = (RestrictInfo *) (lfirst(clist));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see if this clause is an 'or' clause, and, if so,
|
* Check to see if this clause is an 'or' clause, and, if so,
|
||||||
|
@ -118,11 +118,11 @@ create_or_index_paths(Query *root,
|
||||||
pathnode->path.path_cost = cost;
|
pathnode->path.path_cost = cost;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* copy clauseinfo list into path for expensive function
|
* copy restrictinfo list into path for expensive function
|
||||||
* processing -- JMH, 7/7/92
|
* processing -- JMH, 7/7/92
|
||||||
*/
|
*/
|
||||||
pathnode->path.locclauseinfo =
|
pathnode->path.loc_restrictinfo =
|
||||||
set_difference(copyObject((Node *) rel->clauseinfo),
|
set_difference(copyObject((Node *) rel->restrictinfo),
|
||||||
lcons(clausenode, NIL));
|
lcons(clausenode, NIL));
|
||||||
|
|
||||||
#if 0 /* fix xfunc */
|
#if 0 /* fix xfunc */
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.13 1998/09/01 04:29:42 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.14 1999/02/03 20:15:34 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -64,7 +64,7 @@ static void xfunc_form_groups(Stream root, Stream bottom);
|
||||||
static void xfunc_free_stream(Stream root);
|
static void xfunc_free_stream(Stream root);
|
||||||
static Stream xfunc_add_clauses(Stream current);
|
static Stream xfunc_add_clauses(Stream current);
|
||||||
static void xfunc_setup_group(Stream node, Stream bottom);
|
static void xfunc_setup_group(Stream node, Stream bottom);
|
||||||
static Stream xfunc_streaminsert(ClauseInfo clauseinfo, Stream current,
|
static Stream xfunc_streaminsert(RestrictInfo restrictinfo, Stream current,
|
||||||
int clausetype);
|
int clausetype);
|
||||||
static int xfunc_num_relids(Stream node);
|
static int xfunc_num_relids(Stream node);
|
||||||
static StreamPtr xfunc_get_downjoin(Stream node);
|
static StreamPtr xfunc_get_downjoin(Stream node);
|
||||||
|
@ -142,7 +142,7 @@ xfunc_predmig(JoinPath pathnode,/* root of the join tree */
|
||||||
set_downstream(laststream, (StreamPtr) newstream);
|
set_downstream(laststream, (StreamPtr) newstream);
|
||||||
set_downstream(newstream, (StreamPtr) NULL);
|
set_downstream(newstream, (StreamPtr) NULL);
|
||||||
set_pathptr(newstream, (pathPtr) pathnode);
|
set_pathptr(newstream, (pathPtr) pathnode);
|
||||||
set_cinfo(newstream, (ClauseInfo) NULL);
|
set_cinfo(newstream, (RestrictInfo) NULL);
|
||||||
set_clausetype(newstream, XFUNC_UNKNOWN);
|
set_clausetype(newstream, XFUNC_UNKNOWN);
|
||||||
|
|
||||||
/* base case: we're at a leaf, call xfunc_series_llel */
|
/* base case: we're at a leaf, call xfunc_series_llel */
|
||||||
|
@ -315,7 +315,7 @@ xfunc_complete_stream(Stream stream)
|
||||||
static bool
|
static bool
|
||||||
xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath)
|
xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath)
|
||||||
{
|
{
|
||||||
ClauseInfo clauseinfo = get_cinfo(pullme);
|
RestrictInfo restrictinfo = get_cinfo(pullme);
|
||||||
bool progress = false;
|
bool progress = false;
|
||||||
Stream upjoin,
|
Stream upjoin,
|
||||||
orignode,
|
orignode,
|
||||||
|
@ -325,7 +325,7 @@ xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath)
|
||||||
/* find node in origstream that contains clause */
|
/* find node in origstream that contains clause */
|
||||||
for (orignode = origstream;
|
for (orignode = origstream;
|
||||||
orignode != (Stream) NULL
|
orignode != (Stream) NULL
|
||||||
&& get_cinfo(orignode) != clauseinfo;
|
&& get_cinfo(orignode) != restrictinfo;
|
||||||
orignode = (Stream) get_downstream(orignode))
|
orignode = (Stream) get_downstream(orignode))
|
||||||
/* empty body in for loop */ ;
|
/* empty body in for loop */ ;
|
||||||
if (!orignode)
|
if (!orignode)
|
||||||
|
@ -348,13 +348,13 @@ xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath)
|
||||||
whichchild = OUTER;
|
whichchild = OUTER;
|
||||||
else
|
else
|
||||||
whichchild = INNER;
|
whichchild = INNER;
|
||||||
clauseinfo = xfunc_pullup((Path) get_pathptr((Stream) get_downstream(upjoin)),
|
restrictinfo = xfunc_pullup((Path) get_pathptr((Stream) get_downstream(upjoin)),
|
||||||
(JoinPath) get_pathptr(upjoin),
|
(JoinPath) get_pathptr(upjoin),
|
||||||
clauseinfo,
|
restrictinfo,
|
||||||
whichchild,
|
whichchild,
|
||||||
get_clausetype(orignode));
|
get_clausetype(orignode));
|
||||||
set_pathptr(pullme, get_pathptr(upjoin));
|
set_pathptr(pullme, get_pathptr(upjoin));
|
||||||
/* pullme has been moved into locclauseinfo */
|
/* pullme has been moved into locrestrictinfo */
|
||||||
set_clausetype(pullme, XFUNC_LOCPRD);
|
set_clausetype(pullme, XFUNC_LOCPRD);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -524,10 +524,10 @@ xfunc_add_clauses(Stream current)
|
||||||
LispValue primjoin;
|
LispValue primjoin;
|
||||||
|
|
||||||
/* first add in the local clauses */
|
/* first add in the local clauses */
|
||||||
foreach(temp, get_locclauseinfo((Path) get_pathptr(current)))
|
foreach(temp, get_loc_restrictinfo((Path) get_pathptr(current)))
|
||||||
{
|
{
|
||||||
topnode =
|
topnode =
|
||||||
xfunc_streaminsert((ClauseInfo) lfirst(temp), topnode,
|
xfunc_streaminsert((RestrictInfo) lfirst(temp), topnode,
|
||||||
XFUNC_LOCPRD);
|
XFUNC_LOCPRD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,11 +535,11 @@ xfunc_add_clauses(Stream current)
|
||||||
if (IsA(get_pathptr(current), JoinPath))
|
if (IsA(get_pathptr(current), JoinPath))
|
||||||
{
|
{
|
||||||
primjoin = xfunc_primary_join((JoinPath) get_pathptr(current));
|
primjoin = xfunc_primary_join((JoinPath) get_pathptr(current));
|
||||||
foreach(temp, get_pathclauseinfo((JoinPath) get_pathptr(current)))
|
foreach(temp, get_pathrestrictinfo((JoinPath) get_pathptr(current)))
|
||||||
{
|
{
|
||||||
if (!equal(get_clause((ClauseInfo) lfirst(temp)), primjoin))
|
if (!equal(get_clause((RestrictInfo) lfirst(temp)), primjoin))
|
||||||
topnode =
|
topnode =
|
||||||
xfunc_streaminsert((ClauseInfo) lfirst(temp), topnode,
|
xfunc_streaminsert((RestrictInfo) lfirst(temp), topnode,
|
||||||
XFUNC_JOINPRD);
|
XFUNC_JOINPRD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -593,7 +593,7 @@ xfunc_setup_group(Stream node, Stream bottom)
|
||||||
** Return new node.
|
** Return new node.
|
||||||
*/
|
*/
|
||||||
static Stream
|
static Stream
|
||||||
xfunc_streaminsert(ClauseInfo clauseinfo,
|
xfunc_streaminsert(RestrictInfo restrictinfo,
|
||||||
Stream current,
|
Stream current,
|
||||||
int clausetype) /* XFUNC_LOCPRD or XFUNC_JOINPRD */
|
int clausetype) /* XFUNC_LOCPRD or XFUNC_JOINPRD */
|
||||||
{
|
{
|
||||||
|
@ -605,7 +605,7 @@ xfunc_streaminsert(ClauseInfo clauseinfo,
|
||||||
set_upstream(current, (StreamPtr) newstream);
|
set_upstream(current, (StreamPtr) newstream);
|
||||||
set_downstream(newstream, (StreamPtr) current);
|
set_downstream(newstream, (StreamPtr) current);
|
||||||
set_pathptr(newstream, get_pathptr(current));
|
set_pathptr(newstream, get_pathptr(current));
|
||||||
set_cinfo(newstream, clauseinfo);
|
set_cinfo(newstream, restrictinfo);
|
||||||
set_clausetype(newstream, clausetype);
|
set_clausetype(newstream, clausetype);
|
||||||
return newstream;
|
return newstream;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.22 1998/09/01 04:29:45 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.23 1999/02/03 20:15:34 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -59,7 +59,7 @@ void
|
||||||
xfunc_trypullup(RelOptInfo rel)
|
xfunc_trypullup(RelOptInfo rel)
|
||||||
{
|
{
|
||||||
LispValue y; /* list ptr */
|
LispValue y; /* list ptr */
|
||||||
ClauseInfo maxcinfo; /* The ClauseInfo to pull up, as
|
RestrictInfo maxcinfo; /* The RestrictInfo to pull up, as
|
||||||
* calculated by xfunc_shouldpull() */
|
* calculated by xfunc_shouldpull() */
|
||||||
JoinPath curpath; /* current path in list */
|
JoinPath curpath; /* current path in list */
|
||||||
int progress; /* has progress been made this time
|
int progress; /* has progress been made this time
|
||||||
|
@ -132,7 +132,7 @@ xfunc_trypullup(RelOptInfo rel)
|
||||||
** xfunc_shouldpull --
|
** xfunc_shouldpull --
|
||||||
** find clause with highest rank, and decide whether to pull it up
|
** find clause with highest rank, and decide whether to pull it up
|
||||||
** from child to parent. Currently we only pullup secondary join clauses
|
** from child to parent. Currently we only pullup secondary join clauses
|
||||||
** that are in the pathclauseinfo. Secondary hash and sort clauses are
|
** that are in the pathrestrictinfo. Secondary hash and sort clauses are
|
||||||
** left where they are.
|
** left where they are.
|
||||||
** If we find an expensive function but decide *not* to pull it up,
|
** If we find an expensive function but decide *not* to pull it up,
|
||||||
** we'd better set the unpruneable flag. -- JMH, 11/11/92
|
** we'd better set the unpruneable flag. -- JMH, 11/11/92
|
||||||
|
@ -146,12 +146,12 @@ xfunc_shouldpull(Query *queryInfo,
|
||||||
Path childpath,
|
Path childpath,
|
||||||
JoinPath parentpath,
|
JoinPath parentpath,
|
||||||
int whichchild,
|
int whichchild,
|
||||||
ClauseInfo * maxcinfopt) /* Out: pointer to clause
|
RestrictInfo * maxcinfopt) /* Out: pointer to clause
|
||||||
* to pullup */
|
* to pullup */
|
||||||
{
|
{
|
||||||
LispValue clauselist,
|
LispValue clauselist,
|
||||||
tmplist; /* lists of clauses */
|
tmplist; /* lists of clauses */
|
||||||
ClauseInfo maxcinfo; /* clause to pullup */
|
RestrictInfo maxcinfo; /* clause to pullup */
|
||||||
LispValue primjoinclause /* primary join clause */
|
LispValue primjoinclause /* primary join clause */
|
||||||
= xfunc_primary_join(parentpath);
|
= xfunc_primary_join(parentpath);
|
||||||
Cost tmprank,
|
Cost tmprank,
|
||||||
|
@ -160,22 +160,22 @@ xfunc_shouldpull(Query *queryInfo,
|
||||||
Cost joincost = 0; /* join cost + primjoinclause cost */
|
Cost joincost = 0; /* join cost + primjoinclause cost */
|
||||||
int retval = XFUNC_LOCPRD;
|
int retval = XFUNC_LOCPRD;
|
||||||
|
|
||||||
clauselist = get_locclauseinfo(childpath);
|
clauselist = get_loc_restrictinfo(childpath);
|
||||||
|
|
||||||
if (clauselist != LispNil)
|
if (clauselist != LispNil)
|
||||||
{
|
{
|
||||||
/* find local predicate with maximum rank */
|
/* find local predicate with maximum rank */
|
||||||
for (tmplist = clauselist,
|
for (tmplist = clauselist,
|
||||||
maxcinfo = (ClauseInfo) lfirst(tmplist),
|
maxcinfo = (RestrictInfo) lfirst(tmplist),
|
||||||
maxrank = xfunc_rank(get_clause(maxcinfo));
|
maxrank = xfunc_rank(get_clause(maxcinfo));
|
||||||
tmplist != LispNil;
|
tmplist != LispNil;
|
||||||
tmplist = lnext(tmplist))
|
tmplist = lnext(tmplist))
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((tmprank = xfunc_rank(get_clause((ClauseInfo) lfirst(tmplist))))
|
if ((tmprank = xfunc_rank(get_clause((RestrictInfo) lfirst(tmplist))))
|
||||||
> maxrank)
|
> maxrank)
|
||||||
{
|
{
|
||||||
maxcinfo = (ClauseInfo) lfirst(tmplist);
|
maxcinfo = (RestrictInfo) lfirst(tmplist);
|
||||||
maxrank = tmprank;
|
maxrank = tmprank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,16 +187,16 @@ xfunc_shouldpull(Query *queryInfo,
|
||||||
* local predicate
|
* local predicate
|
||||||
*/
|
*/
|
||||||
if (is_join(childpath) && xfunc_num_join_clauses((JoinPath) childpath) > 1)
|
if (is_join(childpath) && xfunc_num_join_clauses((JoinPath) childpath) > 1)
|
||||||
for (tmplist = get_pathclauseinfo((JoinPath) childpath);
|
for (tmplist = get_pathrestrictinfo((JoinPath) childpath);
|
||||||
tmplist != LispNil;
|
tmplist != LispNil;
|
||||||
tmplist = lnext(tmplist))
|
tmplist = lnext(tmplist))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (tmplist != LispNil &&
|
if (tmplist != LispNil &&
|
||||||
(tmprank = xfunc_rank(get_clause((ClauseInfo) lfirst(tmplist))))
|
(tmprank = xfunc_rank(get_clause((RestrictInfo) lfirst(tmplist))))
|
||||||
> maxrank)
|
> maxrank)
|
||||||
{
|
{
|
||||||
maxcinfo = (ClauseInfo) lfirst(tmplist);
|
maxcinfo = (RestrictInfo) lfirst(tmplist);
|
||||||
maxrank = tmprank;
|
maxrank = tmprank;
|
||||||
retval = XFUNC_JOINPRD;
|
retval = XFUNC_JOINPRD;
|
||||||
}
|
}
|
||||||
|
@ -260,13 +260,13 @@ xfunc_shouldpull(Query *queryInfo,
|
||||||
** in the query; it's merely a parent for the new childpath.
|
** in the query; it's merely a parent for the new childpath.
|
||||||
** We also have to fix up the path costs of the child and parent.
|
** We also have to fix up the path costs of the child and parent.
|
||||||
**
|
**
|
||||||
** Now returns a pointer to the new pulled-up ClauseInfo. -- JMH, 11/18/92
|
** Now returns a pointer to the new pulled-up RestrictInfo. -- JMH, 11/18/92
|
||||||
*/
|
*/
|
||||||
ClauseInfo
|
RestrictInfo
|
||||||
xfunc_pullup(Query *queryInfo,
|
xfunc_pullup(Query *queryInfo,
|
||||||
Path childpath,
|
Path childpath,
|
||||||
JoinPath parentpath,
|
JoinPath parentpath,
|
||||||
ClauseInfo cinfo, /* clause to pull up */
|
RestrictInfo cinfo, /* clause to pull up */
|
||||||
int whichchild, /* whether child is INNER or OUTER of join */
|
int whichchild, /* whether child is INNER or OUTER of join */
|
||||||
int clausetype) /* whether clause to pull is join or local */
|
int clausetype) /* whether clause to pull is join or local */
|
||||||
{
|
{
|
||||||
|
@ -274,22 +274,22 @@ xfunc_pullup(Query *queryInfo,
|
||||||
RelOptInfo newrel;
|
RelOptInfo newrel;
|
||||||
Cost pulled_selec;
|
Cost pulled_selec;
|
||||||
Cost cost;
|
Cost cost;
|
||||||
ClauseInfo newinfo;
|
RestrictInfo newinfo;
|
||||||
|
|
||||||
/* remove clause from childpath */
|
/* remove clause from childpath */
|
||||||
newkid = (Path) copyObject((Node) childpath);
|
newkid = (Path) copyObject((Node) childpath);
|
||||||
if (clausetype == XFUNC_LOCPRD)
|
if (clausetype == XFUNC_LOCPRD)
|
||||||
{
|
{
|
||||||
set_locclauseinfo(newkid,
|
set_locrestrictinfo(newkid,
|
||||||
xfunc_LispRemove((LispValue) cinfo,
|
xfunc_LispRemove((LispValue) cinfo,
|
||||||
(List) get_locclauseinfo(newkid)));
|
(List) get_loc_restrictinfo(newkid)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
set_pathclauseinfo
|
set_pathrestrictinfo
|
||||||
((JoinPath) newkid,
|
((JoinPath) newkid,
|
||||||
xfunc_LispRemove((LispValue) cinfo,
|
xfunc_LispRemove((LispValue) cinfo,
|
||||||
(List) get_pathclauseinfo((JoinPath) newkid)));
|
(List) get_pathrestrictinfo((JoinPath) newkid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -320,7 +320,7 @@ xfunc_pullup(Query *queryInfo,
|
||||||
* * We copy the cinfo, since it may appear in other plans, and we're
|
* * We copy the cinfo, since it may appear in other plans, and we're
|
||||||
* going * to munge it. -- JMH, 7/22/92
|
* going * to munge it. -- JMH, 7/22/92
|
||||||
*/
|
*/
|
||||||
newinfo = (ClauseInfo) copyObject((Node) cinfo);
|
newinfo = (RestrictInfo) copyObject((Node) cinfo);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* * Fix all vars in the clause * to point to the right varno and
|
* * Fix all vars in the clause * to point to the right varno and
|
||||||
|
@ -329,9 +329,9 @@ xfunc_pullup(Query *queryInfo,
|
||||||
xfunc_fixvars(get_clause(newinfo), newrel, whichchild);
|
xfunc_fixvars(get_clause(newinfo), newrel, whichchild);
|
||||||
|
|
||||||
/* add clause to parentpath, and fix up its cost. */
|
/* add clause to parentpath, and fix up its cost. */
|
||||||
set_locclauseinfo(parentpath,
|
set_locrestrictinfo(parentpath,
|
||||||
lispCons((LispValue) newinfo,
|
lispCons((LispValue) newinfo,
|
||||||
(LispValue) get_locclauseinfo(parentpath)));
|
(LispValue) get_loc_restrictinfo(parentpath)));
|
||||||
/* put new childpath into the path tree */
|
/* put new childpath into the path tree */
|
||||||
if (whichchild == INNER)
|
if (whichchild == INNER)
|
||||||
set_innerjoinpath(parentpath, (pathPtr) newkid);
|
set_innerjoinpath(parentpath, (pathPtr) newkid);
|
||||||
|
@ -771,12 +771,12 @@ xfunc_card_product(Query *queryInfo, Relid relids)
|
||||||
if (tuples)
|
if (tuples)
|
||||||
{ /* not of cardinality 0 */
|
{ /* not of cardinality 0 */
|
||||||
/* factor in the selectivity of all zero-cost clauses */
|
/* factor in the selectivity of all zero-cost clauses */
|
||||||
foreach(cinfonode, get_clauseinfo(currel))
|
foreach(cinfonode, get_restrictinfo(currel))
|
||||||
{
|
{
|
||||||
if (!xfunc_expense(queryInfo, get_clause((ClauseInfo) lfirst(cinfonode))))
|
if (!xfunc_expense(queryInfo, get_clause((RestrictInfo) lfirst(cinfonode))))
|
||||||
tuples *=
|
tuples *=
|
||||||
compute_clause_selec(queryInfo,
|
compute_clause_selec(queryInfo,
|
||||||
get_clause((ClauseInfo) lfirst(cinfonode)),
|
get_clause((RestrictInfo) lfirst(cinfonode)),
|
||||||
LispNil);
|
LispNil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,8 +861,8 @@ xfunc_find_references(LispValue clause)
|
||||||
LispValue
|
LispValue
|
||||||
xfunc_primary_join(JoinPath pathnode)
|
xfunc_primary_join(JoinPath pathnode)
|
||||||
{
|
{
|
||||||
LispValue joinclauselist = get_pathclauseinfo(pathnode);
|
LispValue joinclauselist = get_pathrestrictinfo(pathnode);
|
||||||
ClauseInfo mincinfo;
|
RestrictInfo mincinfo;
|
||||||
LispValue tmplist;
|
LispValue tmplist;
|
||||||
LispValue minclause = LispNil;
|
LispValue minclause = LispNil;
|
||||||
Cost minrank,
|
Cost minrank,
|
||||||
|
@ -903,15 +903,15 @@ xfunc_primary_join(JoinPath pathnode)
|
||||||
if (joinclauselist == LispNil)
|
if (joinclauselist == LispNil)
|
||||||
return LispNil;
|
return LispNil;
|
||||||
|
|
||||||
for (tmplist = joinclauselist, mincinfo = (ClauseInfo) lfirst(joinclauselist),
|
for (tmplist = joinclauselist, mincinfo = (RestrictInfo) lfirst(joinclauselist),
|
||||||
minrank = xfunc_rank(get_clause((ClauseInfo) lfirst(tmplist)));
|
minrank = xfunc_rank(get_clause((RestrictInfo) lfirst(tmplist)));
|
||||||
tmplist != LispNil;
|
tmplist != LispNil;
|
||||||
tmplist = lnext(tmplist))
|
tmplist = lnext(tmplist))
|
||||||
if ((tmprank = xfunc_rank(get_clause((ClauseInfo) lfirst(tmplist))))
|
if ((tmprank = xfunc_rank(get_clause((RestrictInfo) lfirst(tmplist))))
|
||||||
< minrank)
|
< minrank)
|
||||||
{
|
{
|
||||||
minrank = tmprank;
|
minrank = tmprank;
|
||||||
mincinfo = (ClauseInfo) lfirst(tmplist);
|
mincinfo = (RestrictInfo) lfirst(tmplist);
|
||||||
}
|
}
|
||||||
return (LispValue) get_clause(mincinfo);
|
return (LispValue) get_clause(mincinfo);
|
||||||
}
|
}
|
||||||
|
@ -935,16 +935,16 @@ xfunc_get_path_cost(Query *queryInfo, Path pathnode)
|
||||||
* functions, we don't sort.
|
* functions, we don't sort.
|
||||||
*/
|
*/
|
||||||
if (XfuncMode != XFUNC_OFF)
|
if (XfuncMode != XFUNC_OFF)
|
||||||
set_locclauseinfo(pathnode, lisp_qsort(get_locclauseinfo(pathnode),
|
set_locrestrictinfo(pathnode, lisp_qsort(get_loc_restrictinfo(pathnode),
|
||||||
xfunc_cinfo_compare));
|
xfunc_cinfo_compare));
|
||||||
for (tmplist = get_locclauseinfo(pathnode), selec = 1.0;
|
for (tmplist = get_loc_restrictinfo(pathnode), selec = 1.0;
|
||||||
tmplist != LispNil;
|
tmplist != LispNil;
|
||||||
tmplist = lnext(tmplist))
|
tmplist = lnext(tmplist))
|
||||||
{
|
{
|
||||||
cost += (Cost) (xfunc_local_expense(get_clause((ClauseInfo) lfirst(tmplist)))
|
cost += (Cost) (xfunc_local_expense(get_clause((RestrictInfo) lfirst(tmplist)))
|
||||||
* (Cost) get_tuples(get_parent(pathnode)) * selec);
|
* (Cost) get_tuples(get_parent(pathnode)) * selec);
|
||||||
selec *= compute_clause_selec(queryInfo,
|
selec *= compute_clause_selec(queryInfo,
|
||||||
get_clause((ClauseInfo) lfirst(tmplist)),
|
get_clause((RestrictInfo) lfirst(tmplist)),
|
||||||
LispNil);
|
LispNil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -955,17 +955,17 @@ xfunc_get_path_cost(Query *queryInfo, Path pathnode)
|
||||||
if (IsA(pathnode, JoinPath))
|
if (IsA(pathnode, JoinPath))
|
||||||
{
|
{
|
||||||
if (XfuncMode != XFUNC_OFF)
|
if (XfuncMode != XFUNC_OFF)
|
||||||
set_pathclauseinfo((JoinPath) pathnode, lisp_qsort
|
set_pathrestrictinfo((JoinPath) pathnode, lisp_qsort
|
||||||
(get_pathclauseinfo((JoinPath) pathnode),
|
(get_pathrestrictinfo((JoinPath) pathnode),
|
||||||
xfunc_cinfo_compare));
|
xfunc_cinfo_compare));
|
||||||
for (tmplist = get_pathclauseinfo((JoinPath) pathnode), selec = 1.0;
|
for (tmplist = get_pathrestrictinfo((JoinPath) pathnode), selec = 1.0;
|
||||||
tmplist != LispNil;
|
tmplist != LispNil;
|
||||||
tmplist = lnext(tmplist))
|
tmplist = lnext(tmplist))
|
||||||
{
|
{
|
||||||
cost += (Cost) (xfunc_local_expense(get_clause((ClauseInfo) lfirst(tmplist)))
|
cost += (Cost) (xfunc_local_expense(get_clause((RestrictInfo) lfirst(tmplist)))
|
||||||
* (Cost) get_tuples(get_parent(pathnode)) * selec);
|
* (Cost) get_tuples(get_parent(pathnode)) * selec);
|
||||||
selec *= compute_clause_selec(queryInfo,
|
selec *= compute_clause_selec(queryInfo,
|
||||||
get_clause((ClauseInfo) lfirst(tmplist)),
|
get_clause((RestrictInfo) lfirst(tmplist)),
|
||||||
LispNil);
|
LispNil);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1188,14 +1188,14 @@ xfunc_fixvars(LispValue clause, /* clause being pulled up */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Comparison function for lisp_qsort() on a list of ClauseInfo's.
|
** Comparison function for lisp_qsort() on a list of RestrictInfo's.
|
||||||
** arg1 and arg2 should really be of type (ClauseInfo *).
|
** arg1 and arg2 should really be of type (RestrictInfo *).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xfunc_cinfo_compare(void *arg1, void *arg2)
|
xfunc_cinfo_compare(void *arg1, void *arg2)
|
||||||
{
|
{
|
||||||
ClauseInfo info1 = *(ClauseInfo *) arg1;
|
RestrictInfo info1 = *(RestrictInfo *) arg1;
|
||||||
ClauseInfo info2 = *(ClauseInfo *) arg2;
|
RestrictInfo info2 = *(RestrictInfo *) arg2;
|
||||||
|
|
||||||
LispValue clause1 = (LispValue) get_clause(info1),
|
LispValue clause1 = (LispValue) get_clause(info1),
|
||||||
clause2 = (LispValue) get_clause(info2);
|
clause2 = (LispValue) get_clause(info2);
|
||||||
|
@ -1383,7 +1383,7 @@ xfunc_tuple_width(Relation rd)
|
||||||
int
|
int
|
||||||
xfunc_num_join_clauses(JoinPath path)
|
xfunc_num_join_clauses(JoinPath path)
|
||||||
{
|
{
|
||||||
int num = length(get_pathclauseinfo(path));
|
int num = length(get_pathrestrictinfo(path));
|
||||||
|
|
||||||
if (IsA(path, MergePath))
|
if (IsA(path, MergePath))
|
||||||
return num + length(get_path_mergeclauses((MergePath) path));
|
return num + length(get_path_mergeclauses((MergePath) path));
|
||||||
|
@ -1481,7 +1481,7 @@ xfunc_copyrel(RelOptInfo from, RelOptInfo * to)
|
||||||
Node_Copy(from, newnode, alloc, indexkeys);
|
Node_Copy(from, newnode, alloc, indexkeys);
|
||||||
Node_Copy(from, newnode, alloc, ordering);
|
Node_Copy(from, newnode, alloc, ordering);
|
||||||
#endif
|
#endif
|
||||||
Node_Copy(from, newnode, alloc, clauseinfo);
|
Node_Copy(from, newnode, alloc, restrictinfo);
|
||||||
Node_Copy(from, newnode, alloc, joininfo);
|
Node_Copy(from, newnode, alloc, joininfo);
|
||||||
Node_Copy(from, newnode, alloc, innerjoin);
|
Node_Copy(from, newnode, alloc, innerjoin);
|
||||||
Node_Copy(from, newnode, alloc, superrels);
|
Node_Copy(from, newnode, alloc, superrels);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.34 1998/12/04 15:34:05 thomas Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.35 1999/02/03 20:15:37 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
#include "utils/palloc.h"
|
#include "utils/palloc.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
|
|
||||||
#include "optimizer/clauseinfo.h"
|
#include "optimizer/restrictinfo.h"
|
||||||
#include "optimizer/clauses.h"
|
#include "optimizer/clauses.h"
|
||||||
#include "optimizer/planmain.h"
|
#include "optimizer/planmain.h"
|
||||||
#include "optimizer/tlist.h"
|
#include "optimizer/tlist.h"
|
||||||
|
@ -170,7 +170,7 @@ create_scan_node(Path *best_path, List *tlist)
|
||||||
* xfunc_trypullup(), we get the relevant clauses from the path
|
* xfunc_trypullup(), we get the relevant clauses from the path
|
||||||
* itself, not its parent relation. --- JMH, 6/15/92
|
* itself, not its parent relation. --- JMH, 6/15/92
|
||||||
*/
|
*/
|
||||||
scan_clauses = fix_opids(get_actual_clauses(best_path->locclauseinfo));
|
scan_clauses = fix_opids(get_actual_clauses(best_path->loc_restrictinfo));
|
||||||
|
|
||||||
switch (best_path->pathtype)
|
switch (best_path->pathtype)
|
||||||
{
|
{
|
||||||
|
@ -219,7 +219,7 @@ create_join_node(JoinPath *best_path, List *tlist)
|
||||||
inner_node = create_plan((Path *) best_path->innerjoinpath);
|
inner_node = create_plan((Path *) best_path->innerjoinpath);
|
||||||
inner_tlist = inner_node->targetlist;
|
inner_tlist = inner_node->targetlist;
|
||||||
|
|
||||||
clauses = get_actual_clauses(best_path->pathclauseinfo);
|
clauses = get_actual_clauses(best_path->pathinfo);
|
||||||
|
|
||||||
switch (best_path->path.pathtype)
|
switch (best_path->path.pathtype)
|
||||||
{
|
{
|
||||||
|
@ -263,11 +263,11 @@ create_join_node(JoinPath *best_path, List *tlist)
|
||||||
* into this path node. Put them in the qpqual of the plan node. * --
|
* into this path node. Put them in the qpqual of the plan node. * --
|
||||||
* JMH, 6/15/92
|
* JMH, 6/15/92
|
||||||
*/
|
*/
|
||||||
if (get_locclauseinfo(best_path) != NIL)
|
if (get_loc_restrictinfo(best_path) != NIL)
|
||||||
set_qpqual((Plan) retval,
|
set_qpqual((Plan) retval,
|
||||||
nconc(get_qpqual((Plan) retval),
|
nconc(get_qpqual((Plan) retval),
|
||||||
fix_opids(get_actual_clauses
|
fix_opids(get_actual_clauses
|
||||||
(get_locclauseinfo(best_path)))));
|
(get_loc_restrictinfo(best_path)))));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.20 1998/09/01 04:29:50 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.21 1999/02/03 20:15:38 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
extern int Quiet;
|
extern int Quiet;
|
||||||
|
|
||||||
static void add_clause_to_rels(Query *root, List *clause);
|
static void add_clause_to_rels(Query *root, List *clause);
|
||||||
static void add_join_info_to_rels(Query *root, ClauseInfo * clauseinfo,
|
static void add_join_info_to_rels(Query *root, RestrictInfo * restrictinfo,
|
||||||
List *join_relids);
|
List *join_relids);
|
||||||
static void add_vars_to_targetlist(Query *root, List *vars, List *join_relids);
|
static void add_vars_to_targetlist(Query *root, List *vars, List *join_relids);
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ add_missing_vars_to_tlist(Query *root, List *tlist)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* init-base-rels-qual--
|
* init-base-rels-qual--
|
||||||
* Initializes ClauseInfo and JoinInfo fields of relation entries for all
|
* Initializes RestrictInfo and JoinInfo fields of relation entries for all
|
||||||
* relations appearing within clauses. Creates new relation entries if
|
* relations appearing within clauses. Creates new relation entries if
|
||||||
* necessary, adding them to *query-relation-list*.
|
* necessary, adding them to *query-relation-list*.
|
||||||
*
|
*
|
||||||
|
@ -158,9 +158,9 @@ init_base_rels_qual(Query *root, List *clauses)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* add-clause-to-rels--
|
* add-clause-to-rels--
|
||||||
* Add clause information to either the 'ClauseInfo' or 'JoinInfo' field
|
* Add clause information to either the 'RestrictInfo' or 'JoinInfo' field
|
||||||
* of a relation entry(depending on whether or not the clause is a join)
|
* of a relation entry(depending on whether or not the clause is a join)
|
||||||
* by creating a new ClauseInfo node and setting appropriate fields
|
* by creating a new RestrictInfo node and setting appropriate fields
|
||||||
* within the nodes.
|
* within the nodes.
|
||||||
*
|
*
|
||||||
* Returns nothing of interest.
|
* Returns nothing of interest.
|
||||||
|
@ -170,19 +170,19 @@ add_clause_to_rels(Query *root, List *clause)
|
||||||
{
|
{
|
||||||
List *relids;
|
List *relids;
|
||||||
List *vars;
|
List *vars;
|
||||||
ClauseInfo *clauseinfo = makeNode(ClauseInfo);
|
RestrictInfo *restrictinfo = makeNode(RestrictInfo);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve all relids and vars contained within the clause.
|
* Retrieve all relids and vars contained within the clause.
|
||||||
*/
|
*/
|
||||||
clause_get_relids_vars((Node *) clause, &relids, &vars);
|
clause_get_relids_vars((Node *) clause, &relids, &vars);
|
||||||
|
|
||||||
clauseinfo->clause = (Expr *) clause;
|
restrictinfo->clause = (Expr *) clause;
|
||||||
clauseinfo->notclause = contains_not((Node *) clause);
|
restrictinfo->notclause = contains_not((Node *) clause);
|
||||||
clauseinfo->selectivity = 0;
|
restrictinfo->selectivity = 0;
|
||||||
clauseinfo->indexids = NIL;
|
restrictinfo->indexids = NIL;
|
||||||
clauseinfo->mergejoinorder = (MergeOrder *) NULL;
|
restrictinfo->mergejoinorder = (MergeOrder *) NULL;
|
||||||
clauseinfo->hashjoinoperator = (Oid) 0;
|
restrictinfo->hashjoinoperator = (Oid) 0;
|
||||||
|
|
||||||
if (length(relids) == 1)
|
if (length(relids) == 1)
|
||||||
{
|
{
|
||||||
|
@ -204,14 +204,14 @@ add_clause_to_rels(Query *root, List *clause)
|
||||||
* XXX If we have a func clause set selectivity to 1/3, really
|
* XXX If we have a func clause set selectivity to 1/3, really
|
||||||
* need a true selectivity function.
|
* need a true selectivity function.
|
||||||
*/
|
*/
|
||||||
clauseinfo->selectivity = (Cost) 0.3333333;
|
restrictinfo->selectivity = (Cost) 0.3333333;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
clauseinfo->selectivity =
|
restrictinfo->selectivity =
|
||||||
compute_clause_selec(root, (Node *) clause, NIL);
|
compute_clause_selec(root, (Node *) clause, NIL);
|
||||||
}
|
}
|
||||||
rel->clauseinfo = lcons(clauseinfo, rel->clauseinfo);
|
rel->restrictinfo = lcons(restrictinfo, rel->restrictinfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -228,14 +228,14 @@ add_clause_to_rels(Query *root, List *clause)
|
||||||
* XXX If we have a func clause set selectivity to 1/3, really
|
* XXX If we have a func clause set selectivity to 1/3, really
|
||||||
* need a true selectivity function.
|
* need a true selectivity function.
|
||||||
*/
|
*/
|
||||||
clauseinfo->selectivity = (Cost) 0.3333333;
|
restrictinfo->selectivity = (Cost) 0.3333333;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
clauseinfo->selectivity =
|
restrictinfo->selectivity =
|
||||||
compute_clause_selec(root, (Node *) clause, NIL);
|
compute_clause_selec(root, (Node *) clause, NIL);
|
||||||
}
|
}
|
||||||
add_join_info_to_rels(root, clauseinfo, relids);
|
add_join_info_to_rels(root, restrictinfo, relids);
|
||||||
/* we are going to be doing a join, so add var to targetlist */
|
/* we are going to be doing a join, so add var to targetlist */
|
||||||
add_vars_to_targetlist(root, vars, relids);
|
add_vars_to_targetlist(root, vars, relids);
|
||||||
}
|
}
|
||||||
|
@ -243,18 +243,18 @@ add_clause_to_rels(Query *root, List *clause)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* add-join-info-to-rels--
|
* add-join-info-to-rels--
|
||||||
* For every relation participating in a join clause, add 'clauseinfo' to
|
* For every relation participating in a join clause, add 'restrictinfo' to
|
||||||
* the appropriate joininfo node(creating a new one and adding it to the
|
* the appropriate joininfo node(creating a new one and adding it to the
|
||||||
* appropriate rel node if necessary).
|
* appropriate rel node if necessary).
|
||||||
*
|
*
|
||||||
* 'clauseinfo' describes the join clause
|
* 'restrictinfo' describes the join clause
|
||||||
* 'join-relids' is the list of relations participating in the join clause
|
* 'join-relids' is the list of relations participating in the join clause
|
||||||
*
|
*
|
||||||
* Returns nothing.
|
* Returns nothing.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
add_join_info_to_rels(Query *root, ClauseInfo * clauseinfo, List *join_relids)
|
add_join_info_to_rels(Query *root, RestrictInfo * restrictinfo, List *join_relids)
|
||||||
{
|
{
|
||||||
List *join_relid;
|
List *join_relid;
|
||||||
|
|
||||||
|
@ -272,8 +272,8 @@ add_join_info_to_rels(Query *root, ClauseInfo * clauseinfo, List *join_relids)
|
||||||
|
|
||||||
joininfo = find_joininfo_node(get_base_rel(root, lfirsti(join_relid)),
|
joininfo = find_joininfo_node(get_base_rel(root, lfirsti(join_relid)),
|
||||||
other_rels);
|
other_rels);
|
||||||
joininfo->jinfoclauseinfo =
|
joininfo->jinfo_restrictinfo =
|
||||||
lcons(copyObject((void *) clauseinfo), joininfo->jinfoclauseinfo);
|
lcons(copyObject((void *) restrictinfo), joininfo->jinfo_restrictinfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ add_vars_to_targetlist(Query *root, List *vars, List *join_relids)
|
||||||
* init-join-info--
|
* init-join-info--
|
||||||
* Set the MergeJoinable or HashJoinable field for every joininfo node
|
* Set the MergeJoinable or HashJoinable field for every joininfo node
|
||||||
* (within a rel node) and the MergeJoinOrder or HashJoinOp field for
|
* (within a rel node) and the MergeJoinOrder or HashJoinOp field for
|
||||||
* each clauseinfo node(within a joininfo node) for all relations in a
|
* each restrictinfo node(within a joininfo node) for all relations in a
|
||||||
* query.
|
* query.
|
||||||
*
|
*
|
||||||
* Returns nothing.
|
* Returns nothing.
|
||||||
|
@ -335,7 +335,7 @@ init_join_info(List *rel_list)
|
||||||
*z;
|
*z;
|
||||||
RelOptInfo *rel;
|
RelOptInfo *rel;
|
||||||
JoinInfo *joininfo;
|
JoinInfo *joininfo;
|
||||||
ClauseInfo *clauseinfo;
|
RestrictInfo *restrictinfo;
|
||||||
Expr *clause;
|
Expr *clause;
|
||||||
|
|
||||||
foreach(x, rel_list)
|
foreach(x, rel_list)
|
||||||
|
@ -344,10 +344,10 @@ init_join_info(List *rel_list)
|
||||||
foreach(y, rel->joininfo)
|
foreach(y, rel->joininfo)
|
||||||
{
|
{
|
||||||
joininfo = (JoinInfo *) lfirst(y);
|
joininfo = (JoinInfo *) lfirst(y);
|
||||||
foreach(z, joininfo->jinfoclauseinfo)
|
foreach(z, joininfo->jinfo_restrictinfo)
|
||||||
{
|
{
|
||||||
clauseinfo = (ClauseInfo *) lfirst(z);
|
restrictinfo = (RestrictInfo *) lfirst(z);
|
||||||
clause = clauseinfo->clause;
|
clause = restrictinfo->clause;
|
||||||
if (is_joinable((Node *) clause))
|
if (is_joinable((Node *) clause))
|
||||||
{
|
{
|
||||||
MergeOrder *sortop = (MergeOrder *) NULL;
|
MergeOrder *sortop = (MergeOrder *) NULL;
|
||||||
|
@ -360,12 +360,12 @@ init_join_info(List *rel_list)
|
||||||
|
|
||||||
if (sortop)
|
if (sortop)
|
||||||
{
|
{
|
||||||
clauseinfo->mergejoinorder = sortop;
|
restrictinfo->mergejoinorder = sortop;
|
||||||
joininfo->mergejoinable = true;
|
joininfo->mergejoinable = true;
|
||||||
}
|
}
|
||||||
if (hashop)
|
if (hashop)
|
||||||
{
|
{
|
||||||
clauseinfo->hashjoinoperator = hashop;
|
restrictinfo->hashjoinoperator = hashop;
|
||||||
joininfo->hashjoinable = true;
|
joininfo->hashjoinable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.40 1999/02/03 19:31:24 wieck Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.41 1999/02/03 20:15:39 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
/* DATA STRUCTURE CREATION/MANIPULATION ROUTINES */
|
/* DATA STRUCTURE CREATION/MANIPULATION ROUTINES */
|
||||||
#include "nodes/relation.h"
|
#include "nodes/relation.h"
|
||||||
#include "optimizer/clauseinfo.h"
|
#include "optimizer/restrictinfo.h"
|
||||||
#include "optimizer/joininfo.h"
|
#include "optimizer/joininfo.h"
|
||||||
#include "optimizer/keys.h"
|
#include "optimizer/keys.h"
|
||||||
#include "optimizer/ordering.h"
|
#include "optimizer/ordering.h"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.35 1999/02/02 17:46:15 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.36 1999/02/03 20:15:39 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#include "optimizer/internal.h"
|
#include "optimizer/internal.h"
|
||||||
#include "optimizer/clauses.h"
|
#include "optimizer/clauses.h"
|
||||||
#include "optimizer/clauseinfo.h"
|
#include "optimizer/restrictinfo.h"
|
||||||
#include "optimizer/keys.h"
|
#include "optimizer/keys.h"
|
||||||
#include "optimizer/planmain.h"
|
#include "optimizer/planmain.h"
|
||||||
#include "optimizer/tlist.h"
|
#include "optimizer/tlist.h"
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* clauseinfo.c--
|
* restrictinfo.c--
|
||||||
* ClauseInfo node manipulation routines.
|
* RestrictInfo node manipulation routines.
|
||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/clauseinfo.c,v 1.9 1998/09/01 04:30:00 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/clauseinfo.c,v 1.10 1999/02/03 20:15:39 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -18,21 +18,21 @@
|
||||||
|
|
||||||
#include "optimizer/internal.h"
|
#include "optimizer/internal.h"
|
||||||
#include "optimizer/clauses.h"
|
#include "optimizer/clauses.h"
|
||||||
#include "optimizer/clauseinfo.h"
|
#include "optimizer/restrictinfo.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* valid-or-clause--
|
* valid-or-clause--
|
||||||
*
|
*
|
||||||
* Returns t iff the clauseinfo node contains a 'normal' 'or' clause.
|
* Returns t iff the restrictinfo node contains a 'normal' 'or' clause.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
valid_or_clause(ClauseInfo * clauseinfo)
|
valid_or_clause(RestrictInfo * restrictinfo)
|
||||||
{
|
{
|
||||||
if (clauseinfo != NULL &&
|
if (restrictinfo != NULL &&
|
||||||
!single_node((Node *) clauseinfo->clause) &&
|
!single_node((Node *) restrictinfo->clause) &&
|
||||||
!clauseinfo->notclause &&
|
!restrictinfo->notclause &&
|
||||||
or_clause((Node *) clauseinfo->clause))
|
or_clause((Node *) restrictinfo->clause))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
@ -41,19 +41,19 @@ valid_or_clause(ClauseInfo * clauseinfo)
|
||||||
/*
|
/*
|
||||||
* get-actual-clauses--
|
* get-actual-clauses--
|
||||||
*
|
*
|
||||||
* Returns a list containing the clauses from 'clauseinfo-list'.
|
* Returns a list containing the clauses from 'restrictinfo-list'.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
get_actual_clauses(List *clauseinfo_list)
|
get_actual_clauses(List *restrictinfo_list)
|
||||||
{
|
{
|
||||||
List *temp = NIL;
|
List *temp = NIL;
|
||||||
List *result = NIL;
|
List *result = NIL;
|
||||||
ClauseInfo *clause = (ClauseInfo *) NULL;
|
RestrictInfo *clause = (RestrictInfo *) NULL;
|
||||||
|
|
||||||
foreach(temp, clauseinfo_list)
|
foreach(temp, restrictinfo_list)
|
||||||
{
|
{
|
||||||
clause = (ClauseInfo *) lfirst(temp);
|
clause = (RestrictInfo *) lfirst(temp);
|
||||||
result = lappend(result, clause->clause);
|
result = lappend(result, clause->clause);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -69,7 +69,7 @@ get_actual_clauses(List *clauseinfo_list)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_relattvals--
|
* get_relattvals--
|
||||||
* For each member of a list of clauseinfo nodes to be used with an
|
* For each member of a list of restrictinfo nodes to be used with an
|
||||||
* index, create a vectori-long specifying:
|
* index, create a vectori-long specifying:
|
||||||
* the attnos,
|
* the attnos,
|
||||||
* the values of the clause constants, and
|
* the values of the clause constants, and
|
||||||
|
@ -79,13 +79,13 @@ get_actual_clauses(List *clauseinfo_list)
|
||||||
* flag indicating whether the constant is on the left or right should
|
* flag indicating whether the constant is on the left or right should
|
||||||
* always be *SELEC-CONSTANT-RIGHT*.
|
* always be *SELEC-CONSTANT-RIGHT*.
|
||||||
*
|
*
|
||||||
* 'clauseinfo-list' is a list of clauseinfo nodes
|
* 'restrictinfo-list' is a list of restrictinfo nodes
|
||||||
*
|
*
|
||||||
* Returns a list of vectori-longs.
|
* Returns a list of vectori-longs.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
get_relattvals(List *clauseinfo_list,
|
get_relattvals(List *restrictinfo_list,
|
||||||
List **attnos,
|
List **attnos,
|
||||||
List **values,
|
List **values,
|
||||||
List **flags)
|
List **flags)
|
||||||
|
@ -93,17 +93,17 @@ get_relattvals(List *clauseinfo_list,
|
||||||
List *result1 = NIL;
|
List *result1 = NIL;
|
||||||
List *result2 = NIL;
|
List *result2 = NIL;
|
||||||
List *result3 = NIL;
|
List *result3 = NIL;
|
||||||
ClauseInfo *temp = (ClauseInfo *) NULL;
|
RestrictInfo *temp = (RestrictInfo *) NULL;
|
||||||
List *i = NIL;
|
List *i = NIL;
|
||||||
|
|
||||||
foreach(i, clauseinfo_list)
|
foreach(i, restrictinfo_list)
|
||||||
{
|
{
|
||||||
int dummy;
|
int dummy;
|
||||||
AttrNumber attno;
|
AttrNumber attno;
|
||||||
Datum constval;
|
Datum constval;
|
||||||
int flag;
|
int flag;
|
||||||
|
|
||||||
temp = (ClauseInfo *) lfirst(i);
|
temp = (RestrictInfo *) lfirst(i);
|
||||||
get_relattval((Node *) temp->clause, &dummy, &attno, &constval, &flag);
|
get_relattval((Node *) temp->clause, &dummy, &attno, &constval, &flag);
|
||||||
result1 = lappendi(result1, (int) attno);
|
result1 = lappendi(result1, (int) attno);
|
||||||
result2 = lappendi(result2, constval);
|
result2 = lappendi(result2, constval);
|
||||||
|
@ -118,7 +118,7 @@ get_relattvals(List *clauseinfo_list,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_joinvars --
|
* get_joinvars --
|
||||||
* Given a list of join clauseinfo nodes to be used with the index
|
* Given a list of join restrictinfo nodes to be used with the index
|
||||||
* of an inner join relation, return three lists consisting of:
|
* of an inner join relation, return three lists consisting of:
|
||||||
* the attributes corresponding to the inner join relation
|
* the attributes corresponding to the inner join relation
|
||||||
* the value of the inner var clause (always "")
|
* the value of the inner var clause (always "")
|
||||||
|
@ -126,13 +126,13 @@ get_relattvals(List *clauseinfo_list,
|
||||||
* the operator.
|
* the operator.
|
||||||
*
|
*
|
||||||
* 'relid' is the inner join relation
|
* 'relid' is the inner join relation
|
||||||
* 'clauseinfo-list' is a list of qualification clauses to be used with
|
* 'restrictinfo-list' is a list of qualification clauses to be used with
|
||||||
* 'rel'
|
* 'rel'
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
get_joinvars(Oid relid,
|
get_joinvars(Oid relid,
|
||||||
List *clauseinfo_list,
|
List *restrictinfo_list,
|
||||||
List **attnos,
|
List **attnos,
|
||||||
List **values,
|
List **values,
|
||||||
List **flags)
|
List **flags)
|
||||||
|
@ -142,10 +142,10 @@ get_joinvars(Oid relid,
|
||||||
List *result3 = NIL;
|
List *result3 = NIL;
|
||||||
List *temp;
|
List *temp;
|
||||||
|
|
||||||
foreach(temp, clauseinfo_list)
|
foreach(temp, restrictinfo_list)
|
||||||
{
|
{
|
||||||
ClauseInfo *clauseinfo = lfirst(temp);
|
RestrictInfo *restrictinfo = lfirst(temp);
|
||||||
Expr *clause = clauseinfo->clause;
|
Expr *clause = restrictinfo->clause;
|
||||||
|
|
||||||
if (IsA(get_leftop(clause), Var) &&
|
if (IsA(get_leftop(clause), Var) &&
|
||||||
(relid == (get_leftop(clause))->varno))
|
(relid == (get_leftop(clause))->varno))
|
||||||
|
@ -170,19 +170,19 @@ get_joinvars(Oid relid,
|
||||||
/*
|
/*
|
||||||
* get_opnos--
|
* get_opnos--
|
||||||
* Create and return a list containing the clause operators of each member
|
* Create and return a list containing the clause operators of each member
|
||||||
* of a list of clauseinfo nodes to be used with an index.
|
* of a list of restrictinfo nodes to be used with an index.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
get_opnos(List *clauseinfo_list)
|
get_opnos(List *restrictinfo_list)
|
||||||
{
|
{
|
||||||
ClauseInfo *temp = (ClauseInfo *) NULL;
|
RestrictInfo *temp = (RestrictInfo *) NULL;
|
||||||
List *result = NIL;
|
List *result = NIL;
|
||||||
List *i = NIL;
|
List *i = NIL;
|
||||||
|
|
||||||
foreach(i, clauseinfo_list)
|
foreach(i, restrictinfo_list)
|
||||||
{
|
{
|
||||||
temp = (ClauseInfo *) lfirst(i);
|
temp = (RestrictInfo *) lfirst(i);
|
||||||
result =
|
result =
|
||||||
lappendi(result,
|
lappendi(result,
|
||||||
(((Oper *) temp->clause->oper)->opno));
|
(((Oper *) temp->clause->oper)->opno));
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.10 1998/09/01 04:30:04 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.11 1999/02/03 20:15:42 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -81,7 +81,7 @@ find_secondary_index(Query *root, Oid relid)
|
||||||
indexnode->unorderedpath = NULL;
|
indexnode->unorderedpath = NULL;
|
||||||
indexnode->cheapestpath = NULL;
|
indexnode->cheapestpath = NULL;
|
||||||
indexnode->pruneable = true;
|
indexnode->pruneable = true;
|
||||||
indexnode->clauseinfo = NIL;
|
indexnode->restrictinfo = NIL;
|
||||||
indexnode->joininfo = NIL;
|
indexnode->joininfo = NIL;
|
||||||
indexnode->innerjoin = NIL;
|
indexnode->innerjoin = NIL;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.12 1998/09/01 04:30:05 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.13 1999/02/03 20:15:42 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -71,7 +71,7 @@ find_joininfo_node(RelOptInfo * this_rel, List *join_relids)
|
||||||
{
|
{
|
||||||
joininfo = makeNode(JoinInfo);
|
joininfo = makeNode(JoinInfo);
|
||||||
joininfo->otherrels = join_relids;
|
joininfo->otherrels = join_relids;
|
||||||
joininfo->jinfoclauseinfo = NIL;
|
joininfo->jinfo_restrictinfo = NIL;
|
||||||
joininfo->mergejoinable = false;
|
joininfo->mergejoinable = false;
|
||||||
joininfo->hashjoinable = false;
|
joininfo->hashjoinable = false;
|
||||||
joininfo->inactive = false;
|
joininfo->inactive = false;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.14 1999/02/02 23:53:25 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.15 1999/02/03 20:15:42 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "optimizer/internal.h"
|
#include "optimizer/internal.h"
|
||||||
#include "optimizer/pathnode.h"
|
#include "optimizer/pathnode.h"
|
||||||
#include "optimizer/clauseinfo.h"
|
#include "optimizer/restrictinfo.h"
|
||||||
#include "optimizer/plancat.h"
|
#include "optimizer/plancat.h"
|
||||||
#include "optimizer/cost.h"
|
#include "optimizer/cost.h"
|
||||||
#include "optimizer/keys.h"
|
#include "optimizer/keys.h"
|
||||||
|
@ -209,11 +209,11 @@ create_seqscan_path(RelOptInfo * rel)
|
||||||
pathnode->keys = NIL;
|
pathnode->keys = NIL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* copy clauseinfo list into path for expensive function processing --
|
* copy restrictinfo list into path for expensive function processing --
|
||||||
* JMH, 7/7/92
|
* JMH, 7/7/92
|
||||||
*/
|
*/
|
||||||
pathnode->locclauseinfo =
|
pathnode->loc_restrictinfo =
|
||||||
(List *) copyObject((Node *) rel->clauseinfo);
|
(List *) copyObject((Node *) rel->restrictinfo);
|
||||||
|
|
||||||
if (rel->relids != NULL)
|
if (rel->relids != NULL)
|
||||||
relid = lfirsti(rel->relids);
|
relid = lfirsti(rel->relids);
|
||||||
|
@ -263,11 +263,11 @@ create_index_path(Query *root,
|
||||||
pathnode->indexqual = NIL;
|
pathnode->indexqual = NIL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* copy clauseinfo list into path for expensive function processing --
|
* copy restrictinfo list into path for expensive function processing --
|
||||||
* JMH, 7/7/92
|
* JMH, 7/7/92
|
||||||
*/
|
*/
|
||||||
pathnode->path.locclauseinfo =
|
pathnode->path.loc_restrictinfo =
|
||||||
set_difference((List *) copyObject((Node *) rel->clauseinfo),
|
set_difference((List *) copyObject((Node *) rel->restrictinfo),
|
||||||
(List *) restriction_clauses);
|
(List *) restriction_clauses);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -410,11 +410,11 @@ create_nestloop_path(RelOptInfo * joinrel,
|
||||||
pathnode->path.parent = joinrel;
|
pathnode->path.parent = joinrel;
|
||||||
pathnode->outerjoinpath = outer_path;
|
pathnode->outerjoinpath = outer_path;
|
||||||
pathnode->innerjoinpath = inner_path;
|
pathnode->innerjoinpath = inner_path;
|
||||||
pathnode->pathclauseinfo = joinrel->clauseinfo;
|
pathnode->pathinfo = joinrel->restrictinfo;
|
||||||
pathnode->path.keys = keys;
|
pathnode->path.keys = keys;
|
||||||
pathnode->path.joinid = NIL;
|
pathnode->path.joinid = NIL;
|
||||||
pathnode->path.outerjoincost = (Cost) 0.0;
|
pathnode->path.outerjoincost = (Cost) 0.0;
|
||||||
pathnode->path.locclauseinfo = NIL;
|
pathnode->path.loc_restrictinfo = NIL;
|
||||||
|
|
||||||
if (keys)
|
if (keys)
|
||||||
{
|
{
|
||||||
|
@ -492,12 +492,12 @@ create_mergejoin_path(RelOptInfo * joinrel,
|
||||||
pathnode->jpath.path.parent = joinrel;
|
pathnode->jpath.path.parent = joinrel;
|
||||||
pathnode->jpath.outerjoinpath = outer_path;
|
pathnode->jpath.outerjoinpath = outer_path;
|
||||||
pathnode->jpath.innerjoinpath = inner_path;
|
pathnode->jpath.innerjoinpath = inner_path;
|
||||||
pathnode->jpath.pathclauseinfo = joinrel->clauseinfo;
|
pathnode->jpath.pathinfo = joinrel->restrictinfo;
|
||||||
pathnode->jpath.path.keys = keys;
|
pathnode->jpath.path.keys = keys;
|
||||||
pathnode->jpath.path.p_ordering.ordtype = MERGE_ORDER;
|
pathnode->jpath.path.p_ordering.ordtype = MERGE_ORDER;
|
||||||
pathnode->jpath.path.p_ordering.ord.merge = order;
|
pathnode->jpath.path.p_ordering.ord.merge = order;
|
||||||
pathnode->path_mergeclauses = mergeclauses;
|
pathnode->path_mergeclauses = mergeclauses;
|
||||||
pathnode->jpath.path.locclauseinfo = NIL;
|
pathnode->jpath.path.loc_restrictinfo = NIL;
|
||||||
pathnode->outersortkeys = outersortkeys;
|
pathnode->outersortkeys = outersortkeys;
|
||||||
pathnode->innersortkeys = innersortkeys;
|
pathnode->innersortkeys = innersortkeys;
|
||||||
pathnode->jpath.path.path_cost =
|
pathnode->jpath.path.path_cost =
|
||||||
|
@ -558,8 +558,8 @@ create_hashjoin_path(RelOptInfo * joinrel,
|
||||||
pathnode->jpath.path.parent = joinrel;
|
pathnode->jpath.path.parent = joinrel;
|
||||||
pathnode->jpath.outerjoinpath = outer_path;
|
pathnode->jpath.outerjoinpath = outer_path;
|
||||||
pathnode->jpath.innerjoinpath = inner_path;
|
pathnode->jpath.innerjoinpath = inner_path;
|
||||||
pathnode->jpath.pathclauseinfo = joinrel->clauseinfo;
|
pathnode->jpath.pathinfo = joinrel->restrictinfo;
|
||||||
pathnode->jpath.path.locclauseinfo = NIL;
|
pathnode->jpath.path.loc_restrictinfo = NIL;
|
||||||
pathnode->jpath.path.keys = keys;
|
pathnode->jpath.path.keys = keys;
|
||||||
pathnode->jpath.path.p_ordering.ordtype = SORTOP_ORDER;
|
pathnode->jpath.path.p_ordering.ordtype = SORTOP_ORDER;
|
||||||
pathnode->jpath.path.p_ordering.ord.sortop = NULL;
|
pathnode->jpath.path.p_ordering.ord.sortop = NULL;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.9 1998/09/01 04:30:11 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.10 1999/02/03 20:15:43 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -51,7 +51,7 @@ get_base_rel(Query *root, int relid)
|
||||||
rel->classlist = NULL;
|
rel->classlist = NULL;
|
||||||
rel->ordering = NULL;
|
rel->ordering = NULL;
|
||||||
rel->relam = InvalidOid;
|
rel->relam = InvalidOid;
|
||||||
rel->clauseinfo = NIL;
|
rel->restrictinfo = NIL;
|
||||||
rel->joininfo = NIL;
|
rel->joininfo = NIL;
|
||||||
rel->innerjoin = NIL;
|
rel->innerjoin = NIL;
|
||||||
rel->superrels = NIL;
|
rel->superrels = NIL;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: nodes.h,v 1.35 1999/01/24 00:28:33 momjian Exp $
|
* $Id: nodes.h,v 1.36 1999/02/03 20:15:46 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -79,7 +79,7 @@ typedef enum NodeTag
|
||||||
T_OrderKey,
|
T_OrderKey,
|
||||||
T_JoinKey,
|
T_JoinKey,
|
||||||
T_MergeOrder,
|
T_MergeOrder,
|
||||||
T_ClauseInfo,
|
T_RestrictInfo,
|
||||||
T_JoinMethod,
|
T_JoinMethod,
|
||||||
T_HInfo,
|
T_HInfo,
|
||||||
T_MInfo,
|
T_MInfo,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: relation.h,v 1.11 1998/09/01 04:36:51 momjian Exp $
|
* $Id: relation.h,v 1.12 1999/02/03 20:15:46 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -60,7 +60,7 @@ typedef List *Relid;
|
||||||
* * The presence of the remaining fields depends on the restrictions
|
* * The presence of the remaining fields depends on the restrictions
|
||||||
* and joins which the relation participates in:
|
* and joins which the relation participates in:
|
||||||
*
|
*
|
||||||
* clauseinfo - List of ClauseInfo nodes, containing info about each
|
* restrictinfo - List of RestrictInfo nodes, containing info about each
|
||||||
* qualification clause in which this relation participates
|
* qualification clause in which this relation participates
|
||||||
* joininfo - List of JoinInfo nodes, containing info about each join
|
* joininfo - List of JoinInfo nodes, containing info about each join
|
||||||
* clause in which this relation participates
|
* clause in which this relation participates
|
||||||
|
@ -102,7 +102,7 @@ typedef struct RelOptInfo
|
||||||
|
|
||||||
/* used by various scans and joins: */
|
/* used by various scans and joins: */
|
||||||
Oid *ordering; /* OID of operators in sort order */
|
Oid *ordering; /* OID of operators in sort order */
|
||||||
List *clauseinfo; /* restriction clauses */
|
List *restrictinfo; /* restriction clauses */
|
||||||
List *joininfo; /* join clauses */
|
List *joininfo; /* join clauses */
|
||||||
List *innerjoin;
|
List *innerjoin;
|
||||||
List *superrels;
|
List *superrels;
|
||||||
|
@ -149,7 +149,7 @@ typedef struct Path
|
||||||
List *keys;
|
List *keys;
|
||||||
Cost outerjoincost;
|
Cost outerjoincost;
|
||||||
Relid joinid;
|
Relid joinid;
|
||||||
List *locclauseinfo;
|
List *loc_restrictinfo;
|
||||||
} Path;
|
} Path;
|
||||||
|
|
||||||
typedef struct IndexPath
|
typedef struct IndexPath
|
||||||
|
@ -164,7 +164,7 @@ typedef struct IndexPath
|
||||||
typedef struct JoinPath
|
typedef struct JoinPath
|
||||||
{
|
{
|
||||||
Path path;
|
Path path;
|
||||||
List *pathclauseinfo;
|
List *pathinfo;
|
||||||
Path *outerjoinpath;
|
Path *outerjoinpath;
|
||||||
Path *innerjoinpath;
|
Path *innerjoinpath;
|
||||||
} JoinPath;
|
} JoinPath;
|
||||||
|
@ -207,7 +207,7 @@ typedef struct JoinKey
|
||||||
* clause info
|
* clause info
|
||||||
*******/
|
*******/
|
||||||
|
|
||||||
typedef struct ClauseInfo
|
typedef struct RestrictInfo
|
||||||
{
|
{
|
||||||
NodeTag type;
|
NodeTag type;
|
||||||
Expr *clause; /* should be an OP clause */
|
Expr *clause; /* should be an OP clause */
|
||||||
|
@ -221,7 +221,7 @@ typedef struct ClauseInfo
|
||||||
/* hashjoin only */
|
/* hashjoin only */
|
||||||
Oid hashjoinoperator;
|
Oid hashjoinoperator;
|
||||||
Relid cinfojoinid;
|
Relid cinfojoinid;
|
||||||
} ClauseInfo;
|
} RestrictInfo;
|
||||||
|
|
||||||
typedef struct JoinMethod
|
typedef struct JoinMethod
|
||||||
{
|
{
|
||||||
|
@ -246,7 +246,7 @@ typedef struct JoinInfo
|
||||||
{
|
{
|
||||||
NodeTag type;
|
NodeTag type;
|
||||||
List *otherrels;
|
List *otherrels;
|
||||||
List *jinfoclauseinfo;
|
List *jinfo_restrictinfo;
|
||||||
bool mergejoinable;
|
bool mergejoinable;
|
||||||
bool hashjoinable;
|
bool hashjoinable;
|
||||||
bool inactive;
|
bool inactive;
|
||||||
|
@ -271,7 +271,7 @@ typedef struct Iter
|
||||||
** pathptr -- pointer to the current path node
|
** pathptr -- pointer to the current path node
|
||||||
** cinfo -- if NULL, this stream node referes to the path node.
|
** cinfo -- if NULL, this stream node referes to the path node.
|
||||||
** Otherwise this is a pointer to the current clause.
|
** Otherwise this is a pointer to the current clause.
|
||||||
** clausetype -- whether cinfo is in locclauseinfo or pathclauseinfo in the
|
** clausetype -- whether cinfo is in loc_restrictinfo or pathinfo in the
|
||||||
** path node
|
** path node
|
||||||
** upstream -- linked list pointer upwards
|
** upstream -- linked list pointer upwards
|
||||||
** downstream -- ditto, downwards
|
** downstream -- ditto, downwards
|
||||||
|
@ -285,7 +285,7 @@ typedef struct Stream
|
||||||
{
|
{
|
||||||
NodeTag type;
|
NodeTag type;
|
||||||
Path *pathptr;
|
Path *pathptr;
|
||||||
ClauseInfo *cinfo;
|
RestrictInfo *cinfo;
|
||||||
int *clausetype;
|
int *clausetype;
|
||||||
struct Stream *upstream;
|
struct Stream *upstream;
|
||||||
struct Stream *downstream;
|
struct Stream *downstream;
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* clauseinfo.h--
|
|
||||||
* prototypes for clauseinfo.c.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
|
||||||
*
|
|
||||||
* $Id: clauseinfo.h,v 1.9 1998/09/01 04:36:52 momjian Exp $
|
|
||||||
*
|
|
||||||
*-------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#ifndef CLAUSEINFO_H
|
|
||||||
#define CLAUSEINFO_H
|
|
||||||
|
|
||||||
#include "nodes/pg_list.h"
|
|
||||||
#include "nodes/relation.h"
|
|
||||||
|
|
||||||
extern bool valid_or_clause(ClauseInfo * clauseinfo);
|
|
||||||
extern List *get_actual_clauses(List *clauseinfo_list);
|
|
||||||
extern void get_relattvals(List *clauseinfo_list, List **attnos,
|
|
||||||
List **values, List **flags);
|
|
||||||
extern void get_joinvars(Oid relid, List *clauseinfo_list,
|
|
||||||
List **attnos, List **values, List **flags);
|
|
||||||
extern List *get_opnos(List *clauseinfo_list);
|
|
||||||
|
|
||||||
#endif /* CLAUSEINFO_H */
|
|
|
@ -6,7 +6,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: cost.h,v 1.11 1998/09/01 04:36:54 momjian Exp $
|
* $Id: cost.h,v 1.12 1999/02/03 20:15:52 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -52,10 +52,10 @@ extern int page_size(int tuples, int width);
|
||||||
* prototypes for fuctions in clausesel.h--
|
* prototypes for fuctions in clausesel.h--
|
||||||
* routines to compute clause selectivities
|
* routines to compute clause selectivities
|
||||||
*/
|
*/
|
||||||
extern void set_clause_selectivities(List *clauseinfo_list, Cost new_selectivity);
|
extern void set_clause_selectivities(List *restrictinfo_list, Cost new_selectivity);
|
||||||
extern Cost product_selec(List *clauseinfo_list);
|
extern Cost product_selec(List *restrictinfo_list);
|
||||||
extern void set_rest_relselec(Query *root, List *rel_list);
|
extern void set_rest_relselec(Query *root, List *rel_list);
|
||||||
extern void set_rest_selec(Query *root, List *clauseinfo_list);
|
extern void set_rest_selec(Query *root, List *restrictinfo_list);
|
||||||
extern Cost compute_clause_selec(Query *root,
|
extern Cost compute_clause_selec(Query *root,
|
||||||
Node *clause, List *or_selectivities);
|
Node *clause, List *or_selectivities);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: paths.h,v 1.10 1998/09/01 04:37:14 momjian Exp $
|
* $Id: paths.h,v 1.11 1999/02/03 20:15:53 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -28,7 +28,7 @@ extern List *find_paths(Query *root, List *rels);
|
||||||
* routines to generate index paths
|
* routines to generate index paths
|
||||||
*/
|
*/
|
||||||
extern List *find_index_paths(Query *root, RelOptInfo * rel, List *indices,
|
extern List *find_index_paths(Query *root, RelOptInfo * rel, List *indices,
|
||||||
List *clauseinfo_list,
|
List *restrictinfo_list,
|
||||||
List *joininfo_list);
|
List *joininfo_list);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -47,7 +47,7 @@ extern List *create_or_index_paths(Query *root, RelOptInfo * rel, List *clauses)
|
||||||
* hashutils.h
|
* hashutils.h
|
||||||
* routines to deal with hash keys and clauses
|
* routines to deal with hash keys and clauses
|
||||||
*/
|
*/
|
||||||
extern List *group_clauses_by_hashop(List *clauseinfo_list,
|
extern List *group_clauses_by_hashop(List *restrictinfo_list,
|
||||||
int inner_relid);
|
int inner_relid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -68,7 +68,7 @@ extern List *new_join_pathkeys(List *outer_pathkeys,
|
||||||
* mergeutils.h
|
* mergeutils.h
|
||||||
* routines to deal with merge keys and clauses
|
* routines to deal with merge keys and clauses
|
||||||
*/
|
*/
|
||||||
extern List *group_clauses_by_order(List *clauseinfo_list,
|
extern List *group_clauses_by_order(List *restrictinfo_list,
|
||||||
int inner_relid);
|
int inner_relid);
|
||||||
extern MInfo *match_order_mergeinfo(PathOrder *ordering,
|
extern MInfo *match_order_mergeinfo(PathOrder *ordering,
|
||||||
List *mergeinfo_list);
|
List *mergeinfo_list);
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* restrictinfo.h--
|
||||||
|
* prototypes for restrictinfo.c.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
|
*
|
||||||
|
* $Id: restrictinfo.h,v 1.1 1999/02/03 20:15:53 momjian Exp $
|
||||||
|
*
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#ifndef RESTRICTINFO_H
|
||||||
|
#define RESTRICTINFO_H
|
||||||
|
|
||||||
|
#include "nodes/pg_list.h"
|
||||||
|
#include "nodes/relation.h"
|
||||||
|
|
||||||
|
extern bool valid_or_clause(RestrictInfo * restrictinfo);
|
||||||
|
extern List *get_actual_clauses(List *restrictinfo_list);
|
||||||
|
extern void get_relattvals(List *restrictinfo_list, List **attnos,
|
||||||
|
List **values, List **flags);
|
||||||
|
extern void get_joinvars(Oid relid, List *restrictinfo_list,
|
||||||
|
List **attnos, List **values, List **flags);
|
||||||
|
extern List *get_opnos(List *restrictinfo_list);
|
||||||
|
|
||||||
|
#endif /* RESTRICTINFO_H */
|
|
@ -6,7 +6,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: xfunc.h,v 1.10 1998/09/01 04:37:24 momjian Exp $
|
* $Id: xfunc.h,v 1.11 1999/02/03 20:15:53 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -51,8 +51,8 @@ extern int XfuncMode; /* defined in tcop/postgres.c */
|
||||||
/* function prototypes from planner/path/xfunc.c */
|
/* function prototypes from planner/path/xfunc.c */
|
||||||
extern void xfunc_trypullup(RelOptInfo * rel);
|
extern void xfunc_trypullup(RelOptInfo * rel);
|
||||||
extern int xfunc_shouldpull(Path *childpath, JoinPath *parentpath,
|
extern int xfunc_shouldpull(Path *childpath, JoinPath *parentpath,
|
||||||
int whichchild, ClauseInfo * maxcinfopt);
|
int whichchild, RestrictInfo * maxcinfopt);
|
||||||
extern ClauseInfo *xfunc_pullup(Path *childpath, JoinPath *parentpath, ClauseInfo * cinfo,
|
extern RestrictInfo *xfunc_pullup(Path *childpath, JoinPath *parentpath, RestrictInfo * cinfo,
|
||||||
int whichchild, int clausetype);
|
int whichchild, int clausetype);
|
||||||
extern Cost xfunc_rank(Expr *clause);
|
extern Cost xfunc_rank(Expr *clause);
|
||||||
extern Cost xfunc_expense(Query *queryInfo, Expr *clause);
|
extern Cost xfunc_expense(Query *queryInfo, Expr *clause);
|
||||||
|
|
Loading…
Reference in New Issue