Changeset: e7525f899e76 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e7525f899e76
Modified Files:
sql/backends/monet5/sql_optimizer.c
Branch: jit
Log Message:
Improve storage claim calculation
Needed to ensure emptybind operations to injected properly
diffs (85 lines):
diff --git a/sql/backends/monet5/sql_optimizer.c
b/sql/backends/monet5/sql_optimizer.c
--- a/sql/backends/monet5/sql_optimizer.c
+++ b/sql/backends/monet5/sql_optimizer.c
@@ -24,6 +24,27 @@
#include "opt_pipes.h"
/* prepare is set when we can not optimize based on actual size */
+static lng
+SQLgetColumnSize(sql_trans *tr, sql_column *c)
+{
+ lng size = 0;
+ BAT *b = store_funcs.bind_col(tr, c, RDONLY);
+ if (b) {
+ size += getBatSpace(b);
+ BBPunfix(b->batCacheid);
+ }
+ b = store_funcs.bind_col(tr, c, RD_UPD_VAL);
+ if (b) {
+ size += getBatSpace(b);
+ BBPunfix(b->batCacheid);
+ }
+ b = store_funcs.bind_col(tr, c, RD_INS);
+ if (b) {
+ size+= getBatSpace(b);
+ BBPunfix(b->batCacheid);
+ }
+ return size;
+}
static lng
SQLgetSpace(mvc *m, MalBlkPtr mb, int prepare)
{
@@ -42,6 +63,7 @@ SQLgetSpace(mvc *m, MalBlkPtr mb, int pr
sql_schema *s = mvc_bind_schema(m, sname);
sql_table *t = 0;
sql_column *c = 0;
+ size = 0;
if (!s || strcmp(s->base.name, dt_schema) == 0)
continue;
@@ -53,16 +75,11 @@ SQLgetSpace(mvc *m, MalBlkPtr mb, int pr
continue;
if (c && (!isRemote(c->t) && !isMergeTable(c->t))) {
- BAT *b = store_funcs.bind_col(tr, c, access);
- if (b) {
- size= getBatSpace(b);
- if( access == 0)
- space += size; // accumulate
once
- if( !prepare && size == 0 ){
- setFunctionId(p, emptybindRef);
- }
- BBPunfix(b->batCacheid);
- }
+ size = SQLgetColumnSize(tr, c);
+ if( access == 0)
+ space += size; // accumulate once
+ if( !prepare && size == 0 )
+ setFunctionId(p, emptybindRef);
}
}
/* now deal with the update binds, it is only necessary to
identify that there are updats
@@ -85,17 +102,13 @@ SQLgetSpace(mvc *m, MalBlkPtr mb, int pr
if (!s)
continue;
+ /* we have to sum the cost of all three components of a
BAT */
if (c && (!isRemote(c->t) && !isMergeTable(c->t))) {
- BAT *b = store_funcs.bind_col(tr, c,
RD_UPD_VAL);
- if (b) {
- size= getBatSpace(b);
- if( access == 0)
- space += size; // accumulate
once
- if( !prepare && size == 0 ){
- setFunctionId(p, emptybindRef);
- }
- BBPunfix(b->batCacheid);
- }
+ size = SQLgetColumnSize(tr, c);
+ if( access == 0)
+ space += size; // accumulate once
+ if( !prepare && size == 0 )
+ setFunctionId(p, emptybindRef);
}
}
/* ignore index bats for a while
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list