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

Modified Files:
      Tag: Nov2009
        planner.c 
Log Message:
-- 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.87.2.2
retrieving revision 1.87.2.3
diff -u -d -r1.87.2.2 -r1.87.2.3
--- planner.c   18 Nov 2009 09:11:09 -0000      1.87.2.2
+++ planner.c   18 Nov 2009 15:56:55 -0000      1.87.2.3
@@ -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;
@@ -3980,7 +3998,7 @@
                     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) < 5000)
+                    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