Update of /cvsroot/monetdb/sql/src/common
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv8090/src/common

Modified Files:
      Tag: Nov2009
        sql_list.mx 
Log Message:
new optimizer to fix (performance) bug. We should always start grouping with
a sorted column (if its part of a group by list).


Index: sql_list.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/common/sql_list.mx,v
retrieving revision 1.21.2.1
retrieving revision 1.21.2.2
diff -u -d -r1.21.2.1 -r1.21.2.2
--- sql_list.mx 11 Nov 2009 18:20:24 -0000      1.21.2.1
+++ sql_list.mx 20 Nov 2009 13:06:35 -0000      1.21.2.2
@@ -80,7 +80,9 @@
 int
 list_length(list *l)
 {
-       return l->cnt;
+       if (l)
+               return l->cnt;
+       return 0;
 }
 
 list *
@@ -254,6 +256,27 @@
 }
 
 list *
+list_keysort(list *l, int *keys, fdup dup)
+{
+       list *res = list_create(l->destroy);
+       node *n = NULL;
+       int i, j, *pos, cnt = list_length(l);
+
+       pos = (int*)alloca(cnt*sizeof(int));
+       for (n = l->h, i = 0; n; n = n->next, i++) {
+               pos[i] = i;
+       }
+       /* sort descending */
+       GDKqsort_rev(keys, pos, NULL, cnt, sizeof(int), sizeof(int), TYPE_int);
+       for(j=0; j<cnt; j++) {
+               for(n = l->h, i = 0; n && i != pos[j]; n = n->next, i++) 
+                       ;
+               list_append(res, dup(n->data));
+       }
+       return res;
+}
+
+list *
 list_sort(list *l, fkeyvalue key, fdup dup)
 {
        list *res = list_create(l->destroy);


------------------------------------------------------------------------------
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-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to