Hackers,
While playing with the init code I noticed traces of Hellerstein's
"expensive function optimization". It is completely disabled, uses
functions nowhere to be defined, and is out of date. So I removed it.
Here is the patch. Note that it takes out the "pruneable" field from
struct RelOptInfo, since it's not used.
Tom Lane has said a couple of times that he thinks this maybe can be
resurrected; but even if it is, most likely it won't use this code
(what code? These are only hooks.)
(To the patcher: the file src/backend/lib/lispsort.c can also be removed
after this change)
--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Hoy es el primer d�a del resto de mi vida"
Index: src/backend/optimizer/path/allpaths.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql-server/src/backend/optimizer/path/allpaths.c,v
retrieving revision 1.112
diff -c -r1.112 allpaths.c
*** src/backend/optimizer/path/allpaths.c 14 Jan 2004 23:01:55 -0000 1.112
--- src/backend/optimizer/path/allpaths.c 24 Apr 2004 01:53:10 -0000
***************
*** 531,546 ****
{
rel = (RelOptInfo *) lfirst(x);
- #ifdef NOT_USED
-
- /*
- * * for each expensive predicate in each path in each
- * distinct rel, * consider doing pullup -- JMH
- */
- if (XfuncMode != XFUNC_NOPULL && XfuncMode != XFUNC_OFF)
- xfunc_trypullup(rel);
- #endif
-
/* Find and save the cheapest paths for this rel */
set_cheapest(rel);
--- 531,536 ----
Index: src/backend/optimizer/plan/createplan.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql-server/src/backend/optimizer/plan/createplan.c,v
retrieving revision 1.168
diff -c -r1.168 createplan.c
*** src/backend/optimizer/plan/createplan.c 29 Feb 2004 17:36:05 -0000 1.168
--- src/backend/optimizer/plan/createplan.c 24 Apr 2004 01:29:14 -0000
***************
*** 167,185 ****
break;
}
- #ifdef NOT_USED /* fix xfunc */
- /* sort clauses by cost/(1-selectivity) -- JMH 2/26/92 */
- if (XfuncMode != XFUNC_OFF)
- {
- set_qpqual((Plan) plan,
- lisp_qsort(get_qpqual((Plan) plan),
- xfunc_clause_compare));
- if (XfuncMode != XFUNC_NOR)
- /* sort the disjuncts within each clause by cost -- JMH 3/4/92
*/
- xfunc_disjunct_sort(plan->qpqual);
- }
- #endif
-
return plan;
}
--- 167,172 ----
Index: src/backend/optimizer/util/pathnode.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql-server/src/backend/optimizer/util/pathnode.c,v
retrieving revision 1.103
diff -c -r1.103 pathnode.c
*** src/backend/optimizer/util/pathnode.c 29 Mar 2004 19:58:04 -0000 1.103
--- src/backend/optimizer/util/pathnode.c 24 Apr 2004 01:39:45 -0000
***************
*** 243,251 ****
* A path is worthy if it has either a better sort order (better pathkeys)
* or cheaper cost (on either dimension) than any of the existing old paths.
*
! * Unless parent_rel->pruneable is false, we also remove from the rel's
! * pathlist any old paths that are dominated by new_path --- that is,
! * new_path is both cheaper and at least as well ordered.
*
* The pathlist is kept sorted by TOTAL_COST metric, with cheaper paths
* at the front. No code depends on that for correctness; it's simply
--- 243,251 ----
* A path is worthy if it has either a better sort order (better pathkeys)
* or cheaper cost (on either dimension) than any of the existing old paths.
*
! * We also remove from the rel's pathlist any old paths that are dominated
! * by new_path --- that is, new_path is both cheaper and at least as well
! * ordered.
*
* The pathlist is kept sorted by TOTAL_COST metric, with cheaper paths
* at the front. No code depends on that for correctness; it's simply
***************
*** 342,351 ****
}
/*
! * Remove current element from pathlist if dominated by new,
! * unless xfunc told us not to remove any paths.
*/
! if (remove_old && parent_rel->pruneable)
{
List *p1_next = lnext(p1);
--- 342,350 ----
}
/*
! * Remove current element from pathlist if dominated by new.
*/
! if (remove_old)
{
List *p1_next = lnext(p1);
Index: src/backend/optimizer/util/relnode.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql-server/src/backend/optimizer/util/relnode.c,v
retrieving revision 1.55
diff -c -r1.55 relnode.c
*** src/backend/optimizer/util/relnode.c 17 Feb 2004 00:52:53 -0000 1.55
--- src/backend/optimizer/util/relnode.c 24 Apr 2004 01:39:03 -0000
***************
*** 135,141 ****
rel->cheapest_startup_path = NULL;
rel->cheapest_total_path = NULL;
rel->cheapest_unique_path = NULL;
- rel->pruneable = true;
rel->relid = relid;
rel->rtekind = rte->rtekind;
/* min_attr, max_attr, attr_needed, attr_widths are set below */
--- 135,140 ----
***************
*** 291,297 ****
joinrel->cheapest_startup_path = NULL;
joinrel->cheapest_total_path = NULL;
joinrel->cheapest_unique_path = NULL;
- joinrel->pruneable = true;
joinrel->relid = 0; /* indicates not a baserel */
joinrel->rtekind = RTE_JOIN;
joinrel->min_attr = 0;
--- 290,295 ----
Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql-server/src/backend/tcop/postgres.c,v
retrieving revision 1.400
diff -c -r1.400 postgres.c
*** src/backend/tcop/postgres.c 19 Apr 2004 17:42:58 -0000 1.400
--- src/backend/tcop/postgres.c 24 Apr 2004 04:29:40 -0000
***************
*** 89,99 ****
LogStmtLevel log_statement = LOGSTMT_NONE;
- /*
- * Flags for expensive function optimization -- JMH 3/9/92
- */
- int XfuncMode = 0;
-
/* GUC variable for maximum stack depth (measured in kilobytes) */
int max_stack_depth = 2048;
--- 89,94 ----
***************
*** 2223,2229 ****
ctx = debug_context = PGC_POSTMASTER;
gucsource = PGC_S_ARGV; /* initial switches came from command line */
! while ((flag = getopt(argc, argv, "A:B:c:D:d:Eef:FiNOPo:p:S:st:v:W:x:-:")) !=
-1)
switch (flag)
{
case 'A':
--- 2218,2224 ----
ctx = debug_context = PGC_POSTMASTER;
gucsource = PGC_S_ARGV; /* initial switches came from command line */
! while ((flag = getopt(argc, argv, "A:B:c:D:d:Eef:FiNOPo:p:S:st:v:W:-:")) != -1)
switch (flag)
{
case 'A':
***************
*** 2459,2497 ****
pg_usleep(atoi(optarg)*1000000L);
break;
- case 'x':
- #ifdef NOT_USED /* planner/xfunc.h */
-
- /*
- * control joey hellerstein's expensive function
- * optimization
- */
- if (XfuncMode != 0)
- {
- elog(WARNING, "only one -x flag is allowed");
- errs++;
- break;
- }
- if (strcmp(optarg, "off") == 0)
- XfuncMode = XFUNC_OFF;
- else if (strcmp(optarg, "nor") == 0)
- XfuncMode = XFUNC_NOR;
- else if (strcmp(optarg, "nopull") == 0)
- XfuncMode = XFUNC_NOPULL;
- else if (strcmp(optarg, "nopm") == 0)
- XfuncMode = XFUNC_NOPM;
- else if (strcmp(optarg, "pullall") == 0)
- XfuncMode = XFUNC_PULLALL;
- else if (strcmp(optarg, "wait") == 0)
- XfuncMode = XFUNC_WAIT;
- else
- {
- elog(WARNING, "use -x
{off,nor,nopull,nopm,pullall,wait}");
- errs++;
- }
- #endif
- break;
-
case 'c':
case '-':
{
--- 2454,2459 ----
Index: src/include/nodes/relation.h
===================================================================
RCS file: /home/alvherre/cvs/pgsql-server/src/include/nodes/relation.h,v
retrieving revision 1.93
diff -c -r1.93 relation.h
*** src/include/nodes/relation.h 5 Jan 2004 23:39:54 -0000 1.93
--- src/include/nodes/relation.h 24 Apr 2004 01:36:55 -0000
***************
*** 99,106 ****
* (regardless of its ordering)
* cheapest_unique_path - for caching cheapest path to produce unique
* (no duplicates) output from
relation
- * pruneable - flag to let the planner know whether it can prune the
- * pathlist of this RelOptInfo or not.
*
* If the relation is a base relation it will have these fields set:
*
--- 99,104 ----
***************
*** 193,199 ****
struct Path *cheapest_startup_path;
struct Path *cheapest_total_path;
struct Path *cheapest_unique_path;
- bool pruneable;
/* information about a base rel (not set for join rels!) */
Index relid;
--- 191,196 ----
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match