Changeset: 67632495b0d4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/67632495b0d4
Modified Files:
        clients/Tests/MAL-signatures-hge.test
        clients/Tests/MAL-signatures.test
        monetdb5/optimizer/opt_wrapper.c
        monetdb5/optimizer/optimizer.c
        monetdb5/optimizer/optimizer_private.h
        sql/ChangeLog
        sql/backends/monet5/sql_upgrades.c
        sql/scripts/25_debug.sql
        
sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
        sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/emptydb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out
        sql/test/emptydb-previous-upgrade/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade/Tests/upgrade.stable.out.int128
        sql/test/emptydb/Tests/check.stable.out
        sql/test/emptydb/Tests/check.stable.out.int128
        
sql/test/testdb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-previous-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/testdb-previous-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out
        sql/test/testdb-previous-upgrade/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade/Tests/upgrade.stable.out
        sql/test/testdb-upgrade/Tests/upgrade.stable.out.int128
Branch: default
Log Message:

Removed function sys.optimzier_stats() and the collecting of optimizer 
statistics.


diffs (truncated from 543 to 300 lines):

diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -47258,11 +47258,6 @@ getType
 pattern inspect.getType(X_0:any_1):str
 INSPECTtypeName
 Return the concrete type of a variable (expression).
-inspect
-optimizer_stats
-pattern inspect.optimizer_stats() (X_0:bat[:str], X_1:bat[:int], X_2:bat[:lng])
-OPTstatistics
-Get optimizer use statistics, i.e. calls and total time
 io
 print
 pattern io.print(X_0:any_1):void
diff --git a/clients/Tests/MAL-signatures.test 
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -35758,11 +35758,6 @@ getType
 pattern inspect.getType(X_0:any_1):str
 INSPECTtypeName
 Return the concrete type of a variable (expression).
-inspect
-optimizer_stats
-pattern inspect.optimizer_stats() (X_0:bat[:str], X_1:bat[:int], X_2:bat[:lng])
-OPTstatistics
-Get optimizer use statistics, i.e. calls and total time
 io
 print
 pattern io.print(X_0:any_1):void
diff --git a/monetdb5/optimizer/opt_wrapper.c b/monetdb5/optimizer/opt_wrapper.c
--- a/monetdb5/optimizer/opt_wrapper.c
+++ b/monetdb5/optimizer/opt_wrapper.c
@@ -56,53 +56,49 @@
 #include "optimizer_private.h"
 
 // keep the optimizer list sorted
-static struct {
-       const char *nme;
+static const struct {
+       char *nme;
        str (*fcn)(Client, MalBlkPtr, MalStkPtr, InstrPtr);
-       int calls;
-       lng timing;
 } codes[] = {
-       /* most used compound optiimizers at the top */
-       {"defaultpipe", &OPTdefaultpipeImplementation, 0, 0},
-       {"recursivepipe", &OPTdefaultpipeImplementation, 0, 0},
-       {"nomitosispipe", &OPTdefaultpipeImplementation, 0, 0},
-       {"minimalpipe", &OPTminimalpipeImplementation, 0, 0},
-       {"sequentialpipe", &OPTdefaultpipeImplementation, 0, 0},
+       /* most used compound optimizers at the top */
+       {"defaultpipe", &OPTdefaultpipeImplementation},
+       {"minimalpipe", &OPTminimalpipeImplementation},
+       {"recursivepipe", &OPTdefaultpipeImplementation},
+       {"nomitosispipe", &OPTdefaultpipeImplementation},
+       {"sequentialpipe", &OPTdefaultpipeImplementation},
 
        /* all regular MAL optimizers */
-       {"aliases", &OPTaliasesImplementation, 0, 0},
-       {"candidates", &OPTcandidatesImplementation, 0, 0},
-       {"coercions", &OPTcoercionImplementation, 0, 0},
-       {"commonTerms", &OPTcommonTermsImplementation, 0, 0},
-       {"constants", &OPTconstantsImplementation, 0, 0},
-       {"costModel", &OPTcostModelImplementation, 0, 0},
-       {"dataflow", &OPTdataflowImplementation, 0, 0},
-       {"deadcode", &OPTdeadcodeImplementation, 0, 0},
-       {"dict", &OPTdictImplementation, 0, 0},
-       {"emptybind", &OPTemptybindImplementation, 0, 0},
-       {"evaluate", &OPTevaluateImplementation, 0, 0},
-       {"for", &OPTforImplementation, 0, 0},
-       {"garbageCollector", &OPTgarbageCollectorImplementation, 0, 0},
-       {"generator", &OPTgeneratorImplementation, 0, 0},
-       {"inline", &OPTinlineImplementation, 0, 0},
-       {"matpack", &OPTmatpackImplementation, 0, 0},
-       {"mergetable", &OPTmergetableImplementation, 0, 0},
-       {"mitosis", &OPTmitosisImplementation, 0, 0},
-       {"multiplex", &OPTmultiplexImplementation, 0, 0},
-       {"postfix", &OPTpostfixImplementation, 0, 0},
-       {"profiler", &OPTprofilerImplementation, 0, 0},
-       {"projectionpath", &OPTprojectionpathImplementation, 0, 0},
-       {"pushselect", &OPTpushselectImplementation, 0, 0},
-       {"querylog", &OPTquerylogImplementation, 0, 0},
-       {"reduce", &OPTreduceImplementation, 0, 0},
-       {"remap", &OPTremapImplementation, 0, 0},
-       {"remoteQueries", &OPTremoteQueriesImplementation, 0, 0},
-       {"reorder", &OPTreorderImplementation, 0, 0},
-       {0, 0, 0, 0}
+       {"aliases", &OPTaliasesImplementation},
+       {"candidates", &OPTcandidatesImplementation},
+       {"coercions", &OPTcoercionImplementation},
+       {"commonTerms", &OPTcommonTermsImplementation},
+       {"constants", &OPTconstantsImplementation},
+       {"costModel", &OPTcostModelImplementation},
+       {"dataflow", &OPTdataflowImplementation},
+       {"deadcode", &OPTdeadcodeImplementation},
+       {"dict", &OPTdictImplementation},
+       {"emptybind", &OPTemptybindImplementation},
+       {"evaluate", &OPTevaluateImplementation},
+       {"for", &OPTforImplementation},
+       {"garbageCollector", &OPTgarbageCollectorImplementation},
+       {"generator", &OPTgeneratorImplementation},
+       {"inline", &OPTinlineImplementation},
+       {"matpack", &OPTmatpackImplementation},
+       {"mergetable", &OPTmergetableImplementation},
+       {"mitosis", &OPTmitosisImplementation},
+       {"multiplex", &OPTmultiplexImplementation},
+       {"postfix", &OPTpostfixImplementation},
+       {"profiler", &OPTprofilerImplementation},
+       {"projectionpath", &OPTprojectionpathImplementation},
+       {"pushselect", &OPTpushselectImplementation},
+       {"querylog", &OPTquerylogImplementation},
+       {"reduce", &OPTreduceImplementation},
+       {"remap", &OPTremapImplementation},
+       {"remoteQueries", &OPTremoteQueriesImplementation},
+       {"reorder", &OPTreorderImplementation},
+       {0, 0}
 };
 
-static MT_Lock codeslock = MT_LOCK_INITIALIZER(codeslock);
-
 str
 OPTwrapper(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
 {
@@ -111,7 +107,6 @@ OPTwrapper(Client cntxt, MalBlkPtr mb, M
        Symbol s = NULL;
        int i;
        str msg = MAL_SUCCEED;
-       lng clk;
 
        // no optimizer starts with a null byte, initialization sets a zero
        if (cntxt->mode == FINISHCLIENT)
@@ -156,17 +151,10 @@ OPTwrapper(Client cntxt, MalBlkPtr mb, M
                p->token = REMsymbol;
        }
 
-       clk = GDKusec();
        const char *id = getFunctionId(p);
        for (i = 0; codes[i].nme != NULL; i++) {
                if (strcmp(codes[i].nme, id) == 0) {
                        msg = (*codes[i].fcn) (cntxt, mb, stk, p);
-                       clk = GDKusec() - clk;
-                       MT_lock_set(&codeslock);
-                       codes[i].timing += clk;
-                       codes[i].calls++;
-                       MT_lock_unset(&codeslock);
-                       p = pushLng(mb, p, clk);
                        if (msg || mb->errors) {
                                /* we can only return one or the other */
                                if (msg)
@@ -190,45 +178,3 @@ OPTwrapper(Client cntxt, MalBlkPtr mb, M
 
        return MAL_SUCCEED;
 }
-
-str
-OPTstatistics(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
-{
-       bat *nme = getArgReference_bat(stk, p, 0);
-       bat *cnt = getArgReference_bat(stk, p, 1);
-       bat *time = getArgReference_bat(stk, p, 2);
-       BAT *n, *c, *t;
-       int i;
-
-       (void) cntxt;
-       (void) mb;
-       n = COLnew(0, TYPE_str, 256, TRANSIENT);
-       c = COLnew(0, TYPE_int, 256, TRANSIENT);
-       t = COLnew(0, TYPE_lng, 256, TRANSIENT);
-       if (n == NULL || c == NULL || t == NULL) {
-               BBPreclaim(n);
-               BBPreclaim(c);
-               BBPreclaim(t);
-               throw(MAL, "optimizer.statistics", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
-       }
-       MT_lock_set(&codeslock);
-       for (i = 0; codes[i].nme; i++) {
-               if (BUNappend(n, codes[i].nme, false) != GDK_SUCCEED
-                       || BUNappend(c, &codes[i].calls, false) != GDK_SUCCEED
-                       || BUNappend(t, &codes[i].timing, false) != 
GDK_SUCCEED) {
-                       MT_lock_unset(&codeslock);
-                       BBPreclaim(n);
-                       BBPreclaim(c);
-                       BBPreclaim(t);
-                       throw(MAL, "optimizer.statistics", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
-               }
-       }
-       MT_lock_unset(&codeslock);
-       *nme = n->batCacheid;
-       BBPkeepref(n);
-       *cnt = c->batCacheid;
-       BBPkeepref(c);
-       *time = t->batCacheid;
-       BBPkeepref(t);
-       return MAL_SUCCEED;
-}
diff --git a/monetdb5/optimizer/optimizer.c b/monetdb5/optimizer/optimizer.c
--- a/monetdb5/optimizer/optimizer.c
+++ b/monetdb5/optimizer/optimizer.c
@@ -112,9 +112,6 @@ static mel_func optimizer_init_funcs[] =
                                           "Remapping function calls to a their 
multiplex variant"),
        optwrapper_pattern("remoteQueries", "Resolve the multi-table 
definitions"),
        optwrapper_pattern("reorder", "Reorder by dataflow dependencies"),
-       pattern("inspect", "optimizer_stats", OPTstatistics, false,
-                       "Get optimizer use statistics, i.e. calls and total 
time",
-                       args(3, 3, batarg("", str), batarg("", int), batarg("", 
lng))),
        optwrapper_pattern("pushselect", "Push selects down projections"),
        optwrapper_pattern("postfix", "Postfix the plan,e.g. pushing 
projections"),
        optwrapper_pattern("strimps", "Use strimps index if appropriate"),
diff --git a/monetdb5/optimizer/optimizer_private.h 
b/monetdb5/optimizer/optimizer_private.h
--- a/monetdb5/optimizer/optimizer_private.h
+++ b/monetdb5/optimizer/optimizer_private.h
@@ -17,4 +17,3 @@
 #endif
 
 str OPTwrapper(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
-str OPTstatistics(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
diff --git a/sql/ChangeLog b/sql/ChangeLog
--- a/sql/ChangeLog
+++ b/sql/ChangeLog
@@ -1,6 +1,9 @@
 # ChangeLog file for sql
 # This file is updated with Maddlog
 
+* Mon Sep 15 2025 Sjoerd Mullender <[email protected]>
+- Removed table returning function sys.optimizer_stats().
+
 * Tue Aug 26 2025 Sjoerd Mullender <[email protected]>
 - There are new types "inet4" and "inet6" which can hold respecitvely
   IPv4 and IPv6 internet addresses without CIDR network mask
diff --git a/sql/backends/monet5/sql_upgrades.c 
b/sql/backends/monet5/sql_upgrades.c
--- a/sql/backends/monet5/sql_upgrades.c
+++ b/sql/backends/monet5/sql_upgrades.c
@@ -4906,7 +4906,7 @@ sql_update_snapshot(Client c, mvc *sql, 
 }
 
 static str
-sql_update_inet46(Client c, mvc *sql, sql_schema *s)
+sql_update_default(Client c, mvc *sql, sql_schema *s)
 {
        char *err;
        res_table *output;
@@ -5145,6 +5145,13 @@ sql_update_inet46(Client c, mvc *sql, sq
                BBPreclaim(b);
        }
        res_table_destroy(output);
+
+       if (sql_bind_func(sql, "sys", "optimizer_stats", NULL, NULL, F_UNION, 
true, true)) {
+               const char query[] = "drop function sys.optimizer_stats 
cascade;\n";
+               printf("Running database upgrade commands:\n%s\n", query);
+               err = SQLstatementIntern(c, query, "update", true, false, NULL);
+       }
+
        return err;
 }
 
@@ -5226,7 +5233,7 @@ SQLupgrades(Client c, mvc *m)
                goto handle_error;
        }
 
-       if ((err = sql_update_inet46(c, m, s)) != NULL) {
+       if ((err = sql_update_default(c, m, s)) != NULL) {
                TRC_CRITICAL(SQL_PARSER, "%s\n", err);
                goto handle_error;
        }
diff --git a/sql/scripts/25_debug.sql b/sql/scripts/25_debug.sql
--- a/sql/scripts/25_debug.sql
+++ b/sql/scripts/25_debug.sql
@@ -8,12 +8,6 @@
 -- Copyright August 2008 - 2023 MonetDB B.V.;
 -- Copyright 1997 - July 2008 CWI.
 
--- show the optimizer statistics maintained by the SQL frontend
-create function sys.optimizer_stats()
-       returns table (optname string, count int, timing bigint)
-       external name inspect.optimizer_stats;
-
-
 -- SQL QUERY CACHE
 -- The SQL query cache returns a table with the query plans kept
 
diff --git 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
--- 
a/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
+++ 
b/sql/test/emptydb-previous-upgrade-chain-hge/Tests/upgrade.stable.out.int128
@@ -581,3 +581,6 @@ order by "schema", "table";
 update sys.functions set system = true where not system and schema_id = 2000 
and name in ('contains', 'containsorequal', 'containssymmetric', 'bit_not', 
'bit_and', 'bit_or', 'bit_xor', 'dump_database', 'columnsize');
 update sys._tables set system = true where not system and schema_id = 2000 and 
name in ('ids', 'dependencies_vw', 'describe_user_defined_types', 
'dump_user_defined_types', 'storagemodel', 'tablestoragemodel');
 
+Running database upgrade commands:
+drop function sys.optimizer_stats cascade;
+
diff --git a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out 
b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
--- a/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
+++ b/sql/test/emptydb-previous-upgrade-chain/Tests/upgrade.stable.out
@@ -581,3 +581,6 @@ order by "schema", "table";
 update sys.functions set system = true where not system and schema_id = 2000 
and name in ('contains', 'containsorequal', 'containssymmetric', 'bit_not', 
'bit_and', 'bit_or', 'bit_xor', 'dump_database', 'columnsize');
 update sys._tables set system = true where not system and schema_id = 2000 and 
name in ('ids', 'dependencies_vw', 'describe_user_defined_types', 
'dump_user_defined_types', 'storagemodel', 'tablestoragemodel');
 
+Running database upgrade commands:
+drop function sys.optimizer_stats cascade;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to