Changeset: 116063d25b30 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=116063d25b30 Modified Files: gdk/gdk_select.c Branch: default Log Message:
More aggressive check for using hash-based select. Actually look for existing but not yet loaded hash on both the bat itself and its parent (if it is a view). diffs (57 lines): diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c --- a/gdk/gdk_select.c +++ b/gdk/gdk_select.c @@ -1485,15 +1485,28 @@ BATsubselect(BAT *b, BAT *s, const void } /* refine upper limit by exact size (if known) */ maximum = MIN(maximum, estimate); + parent = VIEWtparent(b); + /* use hash only for equi-join, and then only if b or its + * parent already has a hash, or if b or its parent is + * persistent and the total size wouldn't be too large; check + * for existence of hash last since that may involve I/O */ hash = equi && - (b->batPersistence == PERSISTENT || - ((parent = VIEWtparent(b)) != 0 && - BBPquickdesc(abs(parent),0)->batPersistence == PERSISTENT)) && - (size_t) ATOMsize(b->ttype) >= sizeof(BUN) / 4 && - BATcount(b) * (ATOMsize(b->ttype) + 2 * sizeof(BUN)) < GDK_mem_maxsize / 2; - if (hash && estimate == BUN_NONE && !BATcheckhash(b)) { + (((b->batPersistence == PERSISTENT || + (parent != 0 && + BBPquickdesc(abs(parent),0)->batPersistence == PERSISTENT)) && + (size_t) ATOMsize(b->ttype) >= sizeof(BUN) / 4 && + BATcount(b) * (ATOMsize(b->ttype) + 2 * sizeof(BUN)) < GDK_mem_maxsize / 2) || + (BATcheckhash(b) || + (parent != 0 && + BATcheckhash(BBPdescriptor(-parent))))); + if (hash && + estimate == BUN_NONE && + !BATcheckhash(b) && + (parent == 0 || !BATcheckhash(BBPdescriptor(-parent)))) { /* no exact result size, but we need estimate to choose - * between hash- & scan-select */ + * between hash- & scan-select + * (if we already have a hash, it's a no-brainer: we + * use it) */ BUN cnt = BATcount(b); if (s && BATcount(s) < cnt) cnt = BATcount(s); @@ -1546,7 +1559,7 @@ BATsubselect(BAT *b, BAT *s, const void if (bn == NULL) return NULL; - if (equi && (b->T->hash || hash)) { + if (equi && hash) { ALGODEBUG fprintf(stderr, "#BATsubselect(b=%s#" BUNFMT ",s=%s%s,anti=%d): hash select\n", BATgetId(b), BATcount(b), @@ -1558,7 +1571,7 @@ BATsubselect(BAT *b, BAT *s, const void if (!equi && !b->tvarsized && (b->batPersistence == PERSISTENT || - ((parent = VIEWtparent(b)) != 0 && + (parent != 0 && BBPquickdesc(abs(parent),0)->batPersistence == PERSISTENT))) { /* use imprints if * i) bat is persistent, or parent is persistent _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list