Update of /cvsroot/monetdb/pathfinder/compiler/algebra
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv31739/compiler/algebra

Modified Files:
      Tag: XQFT
        planner.c 
Log Message:
propagated changes of Thursday Nov 19 2009
from the development trunk to the XQFT branch

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2009/11/19 - sjoerd: compiler/algebra/planner.c,1.90
  propagated changes of Wednesday Nov 18 2009 - Thursday Nov 19 2009
  from the Nov2009 branch to the development trunk
  
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    2009/11/18 - tsheyar: compiler/algebra/planner.c,1.87.2.2
    -- Restrict heuristic to avoid blowing up the plan size.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    2009/11/18 - tsheyar: compiler/algebra/planner.c,1.87.2.3
    -- Restrict heuristic to avoid blowing up the plan size (even more).
  
    -- Take functional dependencies for distinct planning into account.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Index: planner.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/algebra/planner.c,v
retrieving revision 1.89
retrieving revision 1.89.2.1
diff -u -d -r1.89 -r1.89.2.1
--- planner.c   7 Oct 2009 13:28:13 -0000       1.89
+++ planner.c   19 Nov 2009 12:12:38 -0000      1.89.2.1
@@ -124,6 +124,8 @@
 /* Easily access subtree-parts */
 #include "child_mnemonic.h"
 
+#define MAGIC_BOUNDARY 5000
+
 /**
  * A ``plan'' is actually a physical algebra operator tree.
  */
@@ -1372,6 +1374,19 @@
 }
 
 /**
+ * Check if a column functionally depends on any other column
+ * in the schema. */
+static bool
+dependent_col (const PFla_op_t *n, PFalg_col_t dependent)
+{
+    for (unsigned int i = 0; i < n->schema.count; i++)
+        if (n->schema.items[i].name != dependent &&
+            PFprop_fd (n->prop, n->schema.items[i].name, dependent))
+            return true;
+    return false;
+}
+
+/**
  * Create physical plan for Distinct operator (duplicate elimination).
  *
  * AFAIK, MonetDB only can do SortDistinct, i.e., sort its input, then
@@ -1389,7 +1404,8 @@
     PFplanlist_t      *sorted;
 
     for (unsigned int i = 0; i < n->schema.count; i++)
-        if (!PFprop_const (n->prop, n->schema.items[i].name))
+        if (!PFprop_const (n->prop, n->schema.items[i].name) &&
+            !dependent_col (n, n->schema.items[i].name))
             ord = PFord_refine (ord,
                                 n->schema.items[i].name,
                                 DIR_ASC /* will be ignored anyway */);
@@ -1418,6 +1434,8 @@
             add_plan (ret,
                       sort_distinct (*(plan_t **) PFarray_at (sorted, i),
                                      PFord_set_at (perms, p)));
+        if (PFarray_last (ret) > MAGIC_BOUNDARY)
+            break;
     }
 
     return ret;
@@ -3976,8 +3994,11 @@
                    if we have only a small number of input orders.
                    (Choose 1000 as otherwise prune_plans() will have
                     to compare more than 1.000.000 orderings for each
-                    plan combination.) */
-                if (PFord_set_count (p->orderings) < 1000)
+                    plan combination.)
+                    Furthermore ensure that we do not increase the plan space
+                    if we already have a large number of possible plans. */
+                if (PFord_set_count (p->orderings) < 1000 &&
+                    PFarray_last (plans) < MAGIC_BOUNDARY)
                     for (i = 0; i < PFord_set_count (orderings); i++) {
                         ord = PFord_set_at (orderings, i);
                         add_plans (plans, ensure_ordering (p, ord));


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to