Changeset: b5dfe833317d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b5dfe833317d
Modified Files:
sql/server/rel_optimize_sel.c
Branch: default
Log Message:
Backed out changeset db1934605b81 and ef2a4e707132.
They cause too much performance loss, unfortunately.
diffs (148 lines):
diff --git a/sql/server/rel_optimize_sel.c b/sql/server/rel_optimize_sel.c
--- a/sql/server/rel_optimize_sel.c
+++ b/sql/server/rel_optimize_sel.c
@@ -510,6 +510,7 @@ typedef struct exp_eq_multi_col_values {
/* we need ->first in order to remove it from the list of multi col
* cmp_eq exps in case that we find another occurrence (with different
values)
*/
+ list *first;
list *cols; /* list of col exps */
list *lvs; /* list of lists of values */
} eq_mcv;
@@ -602,11 +603,20 @@ detect_multicol_cmp_eqs(mvc *sql, list *
for (node *m = sl->h; m; m = m->next)
atms = append(atms,
((sql_exp*)m->data)->r);
mcv->lvs = append(mcv->lvs, atms);
+ /* remove this and the previous occurrence
(which means that's the first time
+ * that we found the *same* multi cmp_eq exp)
+ */
+ if (mcv->first) {
+ list_remove_data(mce_ands, NULL,
mcv->first);
+ mcv->first = NULL;
+ }
+ list_remove_data(mce_ands, NULL, sl);
}
}
if (!found) {
eq_mcv *mcv = SA_NEW(sql->sa, eq_mcv);
+ mcv->first = sl;
mcv->cols = sa_list(sql->sa);
for (node *m = sl->h; m; m = m->next)
mcv->cols = append(mcv->cols,
((sql_exp*)m->data)->l);
@@ -644,10 +654,12 @@ exp_or_chain_groups(list *exps, list **g
}
if (list_length(exps) > 1) {
- if (eq_only)
- *mce_ands = append(*mce_ands, exps);
- else
- *gen_ands = append(*gen_ands, exps);
+ /*if (eq_only)*/
+ /**mce_ands = append(*mce_ands, exps);*/
+ /*else*/
+ /**gen_ands = append(*gen_ands, exps);*/
+ (void) mce_ands;
+ *gen_ands = append(*gen_ands, exps);
} else if (list_length(exps) == 1) {
sql_exp *se = exps->h->data;
@@ -680,7 +692,6 @@ generate_single_col_cmp_in(mvc *sql, sql
return ins;
}
-#if 0
static list *
generate_multi_col_cmp_in(mvc *sql, sql_hash *meqh)
{
@@ -705,13 +716,12 @@ generate_multi_col_cmp_in(mvc *sql, sql_
}
return ins;
}
-#endif
static list *
merge_ors(mvc *sql, list *exps, int *changes)
{
sql_hash *eqh = NULL, *meqh = NULL;
- list *eqs = NULL, *neq = NULL, *gen_ands = NULL, *mce_ands = NULL, *ins
= NULL;//, *mins = NULL;
+ list *eqs = NULL, *neq = NULL, *gen_ands = NULL, *mce_ands = NULL, *ins
= NULL, *mins = NULL;
for (node *n = exps->h; n; n = n->next) {
sql_exp *e = n->data;
@@ -767,47 +777,40 @@ merge_ors(mvc *sql, list *exps, int *cha
if (!col_multival && !multicol_multival)
continue;
- if (col_multival) {
+ if (col_multival)
ins = generate_single_col_cmp_in(sql, eqh);
- /* create the new OR (disjunctive) expression */
- list *new = sa_list(sql->sa);
-
- if (ins) {
- for (int c = 0; c < list_length(ins);
c++)
- (*changes)++;
- list_merge(new, ins, NULL);
+ if (multicol_multival)
+ mins = generate_multi_col_cmp_in(sql, meqh);
+
+ /* create the new OR (disjunctive) expression */
+ list *new = sa_list(sql->sa);
+
+ if (ins)
+ list_merge(new, ins, NULL);
+ if (mins)
+ list_merge(new, mins, NULL);
+
+ if (list_length(eqs))
+ list_merge(new, eqs, NULL);
+ if (list_length(neq))
+ list_merge(new, neq, NULL);
+
+ if (list_length(mce_ands)) {
+ for (node *i = mce_ands->h; i; i = i->next,
(*changes)++) {
+ list *cl = append(sa_list(sql->sa),
exp_conjunctive(sql->sa, i->data));
+ list_merge(new, cl, NULL);
}
-
- /* put everything back together */
- if (list_length(eqs))
- list_merge(new, eqs, NULL);
- if (list_length(neq))
- list_merge(new, neq, NULL);
- if (list_length(mce_ands)) {
- for (node *i = mce_ands->h; i; i =
i->next) {
- list *cl =
append(sa_list(sql->sa),
-
exp_conjunctive(sql->sa, i->data));
- list_merge(new, cl, NULL);
- }
+ }
+ if (list_length(gen_ands)) {
+ for (node *a = gen_ands->h; a; a = a->next,
(*changes)++) {
+ list *gl = append(sa_list(sql->sa),
exp_conjunctive(sql->sa, a->data));
+ list_merge(new, gl, NULL);
}
- if (list_length(gen_ands)) {
- for (node *a = gen_ands->h; a; a =
a->next) {
- list *gl =
append(sa_list(sql->sa),
-
exp_conjunctive(sql->sa, a->data));
- list_merge(new, gl, NULL);
- }
- }
-
- /* replace the old OR exp with the new */
- list_remove_node(exps, NULL, n);
- exps = append(exps, exp_disjunctive(sql->sa,
new));
}
- /*if (multicol_multival) {*/
- /*mins = generate_multi_col_cmp_in(sql, meqh);*/
- /*list_merge(new, mins, NULL);*/
- /*}*/
+ list_remove_node(exps, NULL, n);
+ exps = append(exps, exp_disjunctive(sql->sa, new));
}
}
return exps;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]