Update of /cvsroot/monetdb/MonetDB5/src/optimizer
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18894

Modified Files:
        opt_joinpath.mx 
Log Message:
Experimental sample based join path optimization.


Index: opt_joinpath.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_joinpath.mx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- opt_joinpath.mx     28 Jan 2008 06:14:30 -0000      1.20
+++ opt_joinpath.mx     7 Feb 2008 16:57:18 -0000       1.21
@@ -231,17 +231,33 @@
 The join path optimizer takes a join sequence and
 attempts to minimize the intermediate result.
 The choice depends on a good estimate of intermediate
-results.
+results.SAMPLE_THRESHOLD_lOG
 For the time being, we use a simplistic model, based
 on the assumption that most joins are foreign key joins anyway.
+We use a sample based approach for sizeable  tables.
+The model is derived from the select statement.
 @c
+#define SAMPLE_THRESHOLD_lOG 17
 size_t
 ALGjoinCost(BAT *l, BAT *r)
 {
-       size_t lc, rc;
+       size_t lc, rc, lsize,rsize;
+       BAT *lsample, *rsample, *j;
 
        lc = BATcount(l);
        rc = BATcount(r);
+       if( lc > 100000 || rc > 100000){
+               lsize= MIN(lc/100, (1<<SAMPLE_THRESHOLD_lOG)/3);
+               lsample= BATsample(l,lsize);
+               BBPreclaim(lsample);
+               rsize= MIN(rc/100, (1<<SAMPLE_THRESHOLD_lOG)/3);
+               rsample= BATsample(r,rsize);
+               BBPreclaim(rsample);
+               j= BATjoin(l,r, MAX(lsize,rsize));
+               lsize= BATcount(j);
+               BBPreclaim(j);
+               return lsize;
+       }
        if( l->ttype== TYPE_oid || r->htype== TYPE_oid )
                return MIN(lc,rc);
        return lc * rc;


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

Reply via email to