Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18379
Modified Files:
rel_bin.mx rel_select.mx sql_rel2bin.mx sql_select.mx
sql_statement.mx
Log Message:
reduced the number of select calls (ie switch to uselect as much as currently
possible, remaining are anti-selections of nil and rewriten semijoins into
selects)
use the new anti-select also for not between
Index: sql_rel2bin.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_rel2bin.mx,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- sql_rel2bin.mx 15 Jan 2008 10:42:53 -0000 1.116
+++ sql_rel2bin.mx 6 Mar 2008 08:36:00 -0000 1.117
@@ -271,7 +271,9 @@
{
(void) tpe; /* Stefan: unsed, but required for
list_select() / type fcmp() */
if (sel->type == st_select2 || sel->type == st_uselect2) {
- return 0;
+ /* for now we don't split anti-selects */
+ if ((sel->flag&ANTI) == 0)
+ return 0;
}
return -1;
}
@@ -661,7 +663,7 @@
}
}
stmt_destroy(bits);
- return stmt_select(stmt_idxbat(i, RDONLY), h, cmp_equal);
+ return stmt_uselect(stmt_idxbat(i, RDONLY), h, cmp_equal);
}
static stmt *
Index: rel_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_select.mx,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- rel_select.mx 26 Feb 2008 18:53:42 -0000 1.66
+++ rel_select.mx 6 Mar 2008 08:36:00 -0000 1.67
@@ -876,7 +876,7 @@
lrel = n->data;
/* push down as long as the operators allow this */
- if (lrel->op != op_select && lrel->op != op_join &&
+ if (!is_select(lrel->op) && lrel->op != op_join &&
lrel->op != op_left)
break;
/* pushing through left head of a left join is allowed */
@@ -887,7 +887,7 @@
}
if (!lrel)
return NULL;
- if (p && is_select(p->op)) { /* refine old select */
+ if (p && p->op == op_select) { /* refine old select */
rel_select_add_exp(p, e);
} else {
sql_rel *n = rel_select(lrel, e);
@@ -935,7 +935,7 @@
and the relation is equal.
*/
if (lrel != rrel ||
- (lrel->op != op_select && lrel->op != op_join &&
+ (!is_select(lrel->op) && lrel->op != op_join &&
lrel->op != op_left))
break;
/* pushing through left head of a left join is allowed */
@@ -2096,7 +2096,11 @@
}
if (!e1 || !e2)
return NULL;
- return rel_binop_(sql, e1, e2, NULL, "and");
+ if (sc->token == SQL_NOT_BETWEEN) {
+ return rel_binop_(sql, e1, e2, NULL, "or");
+ } else {
+ return rel_binop_(sql, e1, e2, NULL, "and");
+ }
}
case SQL_NULL:
case SQL_NOT_NULL:
@@ -2393,6 +2397,7 @@
}
if (sc->token == SQL_NOT_BETWEEN) {
+ /* TODO should be 'or' */
rel = rel_compare_exp(sql, rel, le, re1, "<", NULL, f);
rel = rel_compare_exp(sql, rel, exp_dup(le), re2, ">",
NULL, f);
} else {
Index: rel_bin.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/rel_bin.mx,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- rel_bin.mx 25 Feb 2008 19:07:43 -0000 1.35
+++ rel_bin.mx 6 Mar 2008 08:36:00 -0000 1.36
@@ -356,7 +356,7 @@
s = stmt_join(l, stmt_reverse(r),
(comp_type)e->flag);
}
} else {
- s = stmt_select(l, r, (comp_type)e->flag);
+ s = stmt_uselect(l, r, (comp_type)e->flag);
}
} break;
default:
@@ -1122,7 +1122,7 @@
if (s->nrcols == 0){
if (!predicate)
predicate = rel2bin_predicate();
- predicate = stmt_select(predicate, s, cmp_equal);
+ predicate = stmt_uselect(predicate, s, cmp_equal);
} else if (sel) {
sel = stmt_semijoin(sel, s);
} else {
Index: sql_statement.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_statement.mx,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -d -r1.162 -r1.163
--- sql_statement.mx 21 Feb 2008 13:42:18 -0000 1.162
+++ sql_statement.mx 6 Mar 2008 08:36:00 -0000 1.163
@@ -146,6 +146,9 @@
cmp_all = 8
} comp_type;
+/* flag to indicate anti join/select */
+#define ANTI 16
+
typedef struct stmt {
sql_ref ref;
Index: sql_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_select.mx,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -d -r1.223 -r1.224
--- sql_select.mx 28 Feb 2008 15:56:44 -0000 1.223
+++ sql_select.mx 6 Mar 2008 08:36:00 -0000 1.224
@@ -3219,9 +3219,9 @@
return sql_and(sql, scp, j1, j2, f);
}
res = stmt_uselect2(ls, rs1, rs2, 3
- /* aka rs1 <= ls <= rs2 */ );
+ /* aka ls >= rs1 && ls <= rs2 */ );
if (sc->token == SQL_NOT_BETWEEN)
- res = stmt_diff(stmt_dup(ls), res);
+ res->flag |= ANTI; /* aka ls < rs1 || ls > rs2 */
return res;
}
case SQL_LIKE:
@@ -3601,7 +3601,7 @@
}
if (!(s = check_types(sql, bt, s, type_equal)))
return NULL;
- s = stmt_select(t, s, cmp_equal);
+ s = stmt_uselect(t, s, cmp_equal);
if (!found)
scope_add_alias(scp, stmt_dup(t), "row");
@@ -3609,7 +3609,7 @@
stmt *t = first_subset(subset);
t = stmt_const(t, stmt_bool(1));
- return stmt_select(t, s, cmp_equal);
+ return stmt_uselect(t, s, cmp_equal);
}
return s;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins