Changeset: 5b1189a25229 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5b1189a25229 Modified Files: monetdb5/modules/mal/batExtensions.c sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.stable.out sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.stable.err sql/test/Tests/function_syntax.stable.err sql/test/Tests/procedure_syntax.stable.err sql/test/pg_regress/Tests/drop.stable.err sql/test/scoping/Tests/scoping01.stable.err sql/test/subquery/Tests/subquery4.stable.err sql/test/subquery/Tests/subquery4.stable.out Branch: default Log Message:
Compute sorted and revsorted properties at CMDBATappend_bulk. It makes the append slower, but on most cases, the values at the right side of an IN query will be sorted, which later will give a cheaper join. Also approved tests diffs (278 lines): diff --git a/monetdb5/modules/mal/batExtensions.c b/monetdb5/modules/mal/batExtensions.c --- a/monetdb5/modules/mal/batExtensions.c +++ b/monetdb5/modules/mal/batExtensions.c @@ -197,16 +197,37 @@ CMDBATimprintsize(lng *ret, bat *bid) #define append_bulk_imp_fixed_size(TPE) \ do { \ TPE *restrict heap; \ - total = count + inputs; \ + total = number_existing + inputs; \ if (BATextend(b, total) != GDK_SUCCEED) { \ BBPunfix(b->batCacheid); \ throw(MAL,"bat.append_bulk", SQLSTATE(HY013) MAL_MALLOC_FAIL); \ } \ - heap = Tloc(b, count); \ - for (int i = 3, args = pci->argc; i < args; i++, j++) { \ - TPE val = *(TPE*) getArgReference(stk,pci,i); \ - new_nil |= is_##TPE##_nil(val); \ - heap[j] = val; \ + heap = (TPE*) Tloc(b, number_existing); \ + if (!b->tsorted && !b->trevsorted) { \ + for (int i = 3, args = pci->argc; i < args; i++) { \ + TPE next = *(TPE*) getArgReference(stk,pci,i); \ + new_nil |= is_##TPE##_nil(next); \ + heap[j++] = next; \ + } \ + } else { \ + bool sorted = b->tsorted, revsorted = b->trevsorted; \ + TPE prev = *(TPE*) getArgReference(stk,pci,3); \ + new_nil |= is_##TPE##_nil(prev); \ + if (number_existing) { \ + TPE last = *(TPE*) Tloc(b, number_existing - 1); \ + sorted &= prev >= last; \ + revsorted &= prev <= last; \ + } \ + heap[j++] = prev; \ + for (int i = 4, args = pci->argc; i < args; i++) { \ + TPE next = *(TPE*) getArgReference(stk,pci,i); \ + new_nil |= is_##TPE##_nil(next); \ + sorted &= next >= prev; \ + revsorted &= next <= prev; \ + heap[j++] = prev = next; \ + } \ + b->tsorted &= sorted; \ + b->trevsorted &= revsorted; \ } \ } while (0) @@ -216,7 +237,7 @@ CMDBATappend_bulk(Client cntxt, MalBlkPt bat *r = getArgReference_bat(stk, pci, 0), *bid = getArgReference_bat(stk, pci, 1); bit force = *getArgReference_bit(stk, pci, 2), new_nil = 0; BAT *b; - BUN inputs = (BUN)(pci->argc - 3), count = 0, total = 0, j = 0; + BUN inputs = (BUN)(pci->argc - 3), number_existing = 0, total = 0, j = 0; (void) cntxt; if ((b = BATdescriptor(*bid)) == NULL) @@ -224,7 +245,7 @@ CMDBATappend_bulk(Client cntxt, MalBlkPt if (inputs > 0) { uint8_t storage = ATOMstorage(b->ttype); - count = BATcount(b); + number_existing = BATcount(b); if (isaBatType(getArgType(mb, pci, 3))) { /* use BATappend for the bulk case */ gdk_return rt; @@ -244,17 +265,18 @@ CMDBATappend_bulk(Client cntxt, MalBlkPt } else if (b->ttype < TYPE_str && storage == b->ttype) { switch (b->ttype) { case TYPE_bit: - append_bulk_imp_fixed_size(bit); - break; case TYPE_bte: append_bulk_imp_fixed_size(bte); break; case TYPE_sht: append_bulk_imp_fixed_size(sht); break; + case TYPE_date: case TYPE_int: append_bulk_imp_fixed_size(int); break; + case TYPE_daytime: + case TYPE_timestamp: case TYPE_lng: append_bulk_imp_fixed_size(lng); break; @@ -267,15 +289,6 @@ CMDBATappend_bulk(Client cntxt, MalBlkPt case TYPE_dbl: append_bulk_imp_fixed_size(dbl); break; - case TYPE_date: - append_bulk_imp_fixed_size(date); - break; - case TYPE_daytime: - append_bulk_imp_fixed_size(daytime); - break; - case TYPE_timestamp: - append_bulk_imp_fixed_size(timestamp); - break; #ifdef HAVE_HGE case TYPE_hge: append_bulk_imp_fixed_size(hge); @@ -285,7 +298,7 @@ CMDBATappend_bulk(Client cntxt, MalBlkPt assert(0); } BATsetcount(b, total); - if (count == 0) { + if (number_existing == 0) { b->tnil = new_nil; b->tnonil = !new_nil; } else { @@ -293,10 +306,8 @@ CMDBATappend_bulk(Client cntxt, MalBlkPt b->tnonil &= ~new_nil; } b->tkey = BATcount(b) <= 1; - b->tsorted = BATcount(b) <= 1; - b->trevsorted = BATcount(b) <= 1; } else { /* non fixed size, use the conventional way */ - total = count + inputs; + total = number_existing + inputs; if (BATextend(b, total) != GDK_SUCCEED) { BBPunfix(b->batCacheid); throw(MAL,"bat.append_bulk", SQLSTATE(HY013) MAL_MALLOC_FAIL); diff --git a/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.stable.out b/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.stable.out --- a/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.stable.out +++ b/sql/test/BugTracker-2015/Tests/schemadiff.Bug-3778.stable.out @@ -5,7 +5,7 @@ stdout of test 'schemadiff.Bug-3778` in # 15:29:05 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" "mapi_open=true" "--set" "mapi_port=33909" "--set" "mapi_usock=/var/tmp/mtest-7442/.s.monetdb.33909" "--set" "monet_prompt=" "--forcemito" "--set" "mal_listing=2" "--dbpath=/ufs/manegold/_/Monet/HG/default/prefix/_/var/MonetDB/mTests_sql_test_BugTracker-2015" "--set" "mal_listing=0" "--set" "embedded_r=yes" # 15:29:05 > -(mapi:monetdb://monetdb@localhost/worker_0) Parameter 1 has wrong SQL type, expected int(32), but got bigint(64) instead +(mapi:monetdb://monetdb@localhost/worker_0) Parameter 1 has wrong SQL type, expected int, but got bigint instead # 10:44:31 > diff --git a/sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.stable.err b/sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.stable.err --- a/sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.stable.err +++ b/sql/test/BugTracker-2019/Tests/remote-table-non-existent-column.Bug-6750.stable.err @@ -6,7 +6,7 @@ stderr of test 'remote-table-non-existen # 10:42:19 > (mapi:monetdb://monetdb@localhost/node1) Identifier tab1.col2 doesn't exist -(mapi:monetdb://monetdb@localhost/node1) Parameter 1 has wrong SQL type, expected double(53), but got tinyint(8) instead +(mapi:monetdb://monetdb@localhost/node1) Parameter 1 has wrong SQL type, expected double, but got tinyint instead (mapi:monetdb://monetdb@localhost/node1) Merge tables not supported under remote connections # builtin opt gdk_dbpath = /home/ferreira/repositories/MonetDB-default/BUILD/var/monetdb5/dbfarm/demo # builtin opt mapi_port = 50000 diff --git a/sql/test/Tests/function_syntax.stable.err b/sql/test/Tests/function_syntax.stable.err --- a/sql/test/Tests/function_syntax.stable.err +++ b/sql/test/Tests/function_syntax.stable.err @@ -18,7 +18,7 @@ ERROR = !DROP FUNCTION: there are more t CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 QUERY = DROP FUNCTION f2 (int, varchar(1024)); -ERROR = !DROP FUNCTION: no such function 'f2' (int(32), varchar(1024)) +ERROR = !DROP FUNCTION: no such function 'f2' (int, varchar(1024)) CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 QUERY = DROP ALL FUNCTION f1 CASCADE; diff --git a/sql/test/Tests/procedure_syntax.stable.err b/sql/test/Tests/procedure_syntax.stable.err --- a/sql/test/Tests/procedure_syntax.stable.err +++ b/sql/test/Tests/procedure_syntax.stable.err @@ -18,7 +18,7 @@ ERROR = !DROP PROCEDURE: there are more CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 QUERY = DROP PROCEDURE p2 (int, varchar(1024)); -ERROR = !DROP PROCEDURE: no such procedure 'p2' (int(32), varchar(1024)) +ERROR = !DROP PROCEDURE: no such procedure 'p2' (int, varchar(1024)) CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 QUERY = DROP table t1; diff --git a/sql/test/pg_regress/Tests/drop.stable.err b/sql/test/pg_regress/Tests/drop.stable.err --- a/sql/test/pg_regress/Tests/drop.stable.err +++ b/sql/test/pg_regress/Tests/drop.stable.err @@ -82,7 +82,7 @@ ERROR = !syntax error, unexpected sqlNAM CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 QUERY = DROP FUNCTION oldstyle_length(integer, text); -ERROR = !DROP FUNCTION: no such function 'oldstyle_length' (int(32), clob) +ERROR = !DROP FUNCTION: no such function 'oldstyle_length' (int, clob) CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 QUERY = DROP TYPE decimal(7,2); @@ -94,15 +94,15 @@ ERROR = !DROP TYPE: type 'widget' does n CODE = 42S01 MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 QUERY = DROP AGGREGATE newavg (integer); -ERROR = !DROP AGGREGATE: no such aggregate 'newavg' (int(32)) +ERROR = !DROP AGGREGATE: no such aggregate 'newavg' (int) CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 QUERY = DROP AGGREGATE newsum (integer); -ERROR = !DROP AGGREGATE: no such aggregate 'newsum' (int(32)) +ERROR = !DROP AGGREGATE: no such aggregate 'newsum' (int) CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 QUERY = DROP AGGREGATE newcnt (integer); -ERROR = !DROP AGGREGATE: no such aggregate 'newcnt' (int(32)) +ERROR = !DROP AGGREGATE: no such aggregate 'newcnt' (int) CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-30274/.s.monetdb.37685 QUERY = DROP INDEX onek_unique1; diff --git a/sql/test/scoping/Tests/scoping01.stable.err b/sql/test/scoping/Tests/scoping01.stable.err --- a/sql/test/scoping/Tests/scoping01.stable.err +++ b/sql/test/scoping/Tests/scoping01.stable.err @@ -66,7 +66,7 @@ ERROR = !SELECT: identifier 'optimizer' CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-362309/.s.monetdb.34330 QUERY = DROP FUNCTION tests_scopes1(INT); -ERROR = !DROP FUNCTION: no such function 'tests_scopes1' (int(32)) +ERROR = !DROP FUNCTION: no such function 'tests_scopes1' (int) CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-126495/.s.monetdb.31037 QUERY = DECLARE "current_schema" string; --error, cannot declare variables on the global scope diff --git a/sql/test/subquery/Tests/subquery4.stable.err b/sql/test/subquery/Tests/subquery4.stable.err --- a/sql/test/subquery/Tests/subquery4.stable.err +++ b/sql/test/subquery/Tests/subquery4.stable.err @@ -254,11 +254,11 @@ ERROR = !CALL: subqueries not allowed in CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-17674/.s.monetdb.33889 QUERY = SELECT row_number(1) OVER () FROM integers i1; --error, row_number(int) doesn't exist -ERROR = !SELECT: window function 'row_number(int(32))' not found +ERROR = !SELECT: window function 'row_number(int)' not found CODE = 42000 MAPI = (monetdb) /var/tmp/mtest-17674/.s.monetdb.33889 QUERY = SELECT ntile(1,1) OVER () FROM integers i1; --error, ntile(int,int) doesn't exist -ERROR = !SELECT: window function 'ntile(int(32), tinyint(1))' not found +ERROR = !SELECT: window function 'ntile(int, tinyint)' not found CODE = 42000 # 15:41:18 > diff --git a/sql/test/subquery/Tests/subquery4.stable.out b/sql/test/subquery/Tests/subquery4.stable.out --- a/sql/test/subquery/Tests/subquery4.stable.out +++ b/sql/test/subquery/Tests/subquery4.stable.out @@ -395,8 +395,8 @@ stdout of test 'subquery4` in directory % 1 # length [ 1 ] #SELECT upsme(1); -% .%14 # table_name -% %14 # name +% .%2 # table_name +% %2 # name % int # type % 1 # length [ 1 ] @@ -408,8 +408,8 @@ stdout of test 'subquery4` in directory % 1 # length [ 1 ] #SELECT upsme(1); -% .%5 # table_name -% %5 # name +% .%2 # table_name +% %2 # name % int # type % 1 # length [ 1 ] @@ -420,8 +420,8 @@ stdout of test 'subquery4` in directory # RETURN n; #END; #SELECT debugme(1), debugme(2); -% .%3, .%4 # table_name -% %3, %4 # name +% .%4, .%5 # table_name +% %4, %5 # name % boolean, boolean # type % 5, 5 # length [ false, true ] @@ -434,8 +434,8 @@ stdout of test 'subquery4` in directory # RETURN n; #END; #SELECT debugme2(1), debugme2(2); -% .%3, .%4 # table_name -% %3, %4 # name +% .%4, .%5 # table_name +% %4, %5 # name % int, int # type % 1, 1 # length [ 1, 1 ] _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list