Changeset: 9c719ed44ba9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9c719ed44ba9
Modified Files:
sql/server/rel_optimize_others.c
sql/test/BugTracker-2015/Tests/crash.Bug-3736.test
sql/test/Dependencies/Tests/dependency_DBobjects.test
sql/test/Dependencies/Tests/dependency_owner_schema_3.test
sql/test/emptydb/Tests/check.stable.out.int128
Branch: default
Log Message:
add projects around referenced sub relations
let dce optimizer reduce the sub relations
diffs (159 lines):
diff --git a/sql/server/rel_optimize_others.c b/sql/server/rel_optimize_others.c
--- a/sql/server/rel_optimize_others.c
+++ b/sql/server/rel_optimize_others.c
@@ -1028,15 +1028,6 @@ rel_dce_sub(mvc *sql, sql_rel *rel)
return rel;
}
-/*
-sql_rel *
-rel_deadcode_elimination(mvc *sql, sql_rel *rel)
-{
- rel_used(rel);
- return rel_dce_sub(sql, rel);
-}
-*/
-
/* add projects under set ops */
static sql_rel *
rel_add_projects(mvc *sql, sql_rel *rel)
@@ -1044,6 +1035,11 @@ rel_add_projects(mvc *sql, sql_rel *rel)
if (!rel)
return rel;
+ if (rel_is_ref(rel)) {
+ if (!is_project(rel->op) && !is_basetable(rel->op) &&
!is_ddl(rel->op))
+ rel = rel_inplace_project(sql->sa, rel, NULL,
rel_projections(sql, rel, NULL, 1, 1));
+ }
+
switch(rel->op) {
case op_basetable:
case op_truncate:
@@ -1125,19 +1121,17 @@ rel_dce_(mvc *sql, sql_rel *rel)
list *refs = sa_list(sql->sa);
rel_dce_refs(sql, rel, refs);
+ rel = rel_add_projects(sql, rel);
+ rel_used(rel);
+ rel_dce_sub(sql, rel);
if (refs) {
for(node *n = refs->h; n; n = n->next) {
sql_rel *i = n->data;
- while (!rel_is_ref(i) && i->l && !is_base(i->op))
- i = i->l;
if (i)
- rel_used(i);
+ rel_dce_sub(sql, i);
}
}
- rel = rel_add_projects(sql, rel);
- rel_used(rel);
- rel_dce_sub(sql, rel);
return rel;
}
diff --git a/sql/test/BugTracker-2015/Tests/crash.Bug-3736.test
b/sql/test/BugTracker-2015/Tests/crash.Bug-3736.test
--- a/sql/test/BugTracker-2015/Tests/crash.Bug-3736.test
+++ b/sql/test/BugTracker-2015/Tests/crash.Bug-3736.test
@@ -112,33 +112,37 @@ EXPLAIN SHOW DETAILS
Select b.* FROM open_auctions o, bidder b WHERE (select b3.INCREASE from
bidder b3 where b3.id = (select min (b3a.id) from bidder b3a where
b3a.open_auction_id = o.open_auction_id)) * 2 <= (Select b2.INCREASE from
bidder b2 where b2.id = (SELECT MAX (b2a.id) from bidder b2a where
b2a.open_auction_id = o.open_auction_id)) AND o.open_auction_id =
b.open_auction_id
----
REF 1 (2)
-join (
-| table("sys"."open_auctions") [ "open_auctions"."open_auction_id" NOT NULL as
"o"."open_auction_id", "open_auctions"."%TID%" NOT NULL UNIQUE as "o"."%TID%" ],
-| table("sys"."bidder") [ "bidder"."id" NOT NULL UNIQUE HASHCOL as "b"."id",
"bidder"."open_auction_id" NOT NULL as "b"."open_auction_id", "bidder"."date"
NOT NULL as "b"."date", "bidder"."time" NOT NULL as "b"."time",
"bidder"."personref" NOT NULL as "b"."personref", "bidder"."increase" NOT NULL
as "b"."increase", "bidder"."%TID%" NOT NULL UNIQUE as "b"."%TID%" ]
-) [ ("o"."open_auction_id" NOT NULL) = ("b"."open_auction_id" NOT NULL) ]
+project (
+| join (
+| | table("sys"."open_auctions") [ "open_auctions"."open_auction_id" NOT NULL
as "o"."open_auction_id" ],
+| | table("sys"."bidder") [ "bidder"."id" NOT NULL UNIQUE HASHCOL as
"b"."id", "bidder"."open_auction_id" NOT NULL as "b"."open_auction_id",
"bidder"."date" NOT NULL as "b"."date", "bidder"."time" NOT NULL as "b"."time",
"bidder"."personref" NOT NULL as "b"."personref", "bidder"."increase" NOT NULL
as "b"."increase" ]
+| ) [ ("o"."open_auction_id" NOT NULL) = ("b"."open_auction_id" NOT NULL) ]
+) [ "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL ,
"b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL,
"b"."personref" NOT NULL, "b"."increase" NOT NULL ]
REF 2 (2)
-single left outer join (
-| & REF 1 ,
-| project (
-| | join (
-| | | project (
-| | | | table("sys"."bidder") [ "bidder"."id" NOT NULL UNIQUE HASHCOL as
"b3"."id", "bidder"."increase" NOT NULL as "b3"."increase", "bidder"."%TID%"
NOT NULL UNIQUE as "b3"."%TID%" ]
-| | | ) [ "b3"."id" NOT NULL UNIQUE HASHCOL , "b3"."increase" NOT NULL,
"b3"."%TID%" NOT NULL UNIQUE, "b3"."increase" NOT NULL as "%3"."%3" ],
-| | | project (
-| | | | group by (
-| | | | | join (
-| | | | | | table("sys"."bidder") [ "bidder"."id" NOT NULL UNIQUE HASHCOL as
"b3a"."id", "bidder"."open_auction_id" NOT NULL as "b3a"."open_auction_id",
"bidder"."%TID%" NOT NULL UNIQUE as "b3a"."%TID%" ],
-| | | | | | group by (
-| | | | | | | project (
-| | | | | | | | & REF 1
-| | | | | | | ) [ "o"."open_auction_id" NOT NULL ]
-| | | | | | ) [ "o"."open_auction_id" NOT NULL ] [ "o"."open_auction_id" NOT
NULL ]
-| | | | | ) [ ("b3a"."open_auction_id" NOT NULL) = ("o"."open_auction_id" NOT
NULL UNIQUE) ]
-| | | | ) [ "o"."open_auction_id" NOT NULL ] [ "sys"."min" no nil ("b3a"."id"
NOT NULL HASHCOL ) NOT NULL as "%1"."%1", "o"."open_auction_id" NOT NULL ]
-| | | ) [ "o"."open_auction_id" NOT NULL UNIQUE, "%1"."%1" NOT NULL as
"%2"."%2" ]
-| | ) [ ("b3"."id" NOT NULL UNIQUE HASHCOL ) = ("%2"."%2" NOT NULL) ]
-| ) [ "b3"."id" NOT NULL HASHCOL , "b3"."increase" NOT NULL, "b3"."%TID%" NOT
NULL, "%2"."%2" NOT NULL, "%3"."%3" NOT NULL, "o"."open_auction_id" NOT NULL as
"%7"."%7" ]
-) [ ("o"."open_auction_id" NOT NULL) * = ("%7"."%7" NOT NULL) ]
+single project (
+| single left outer join (
+| | & REF 1 ,
+| | project (
+| | | join (
+| | | | project (
+| | | | | table("sys"."bidder") [ "bidder"."id" NOT NULL UNIQUE HASHCOL as
"b3"."id", "bidder"."increase" NOT NULL as "b3"."increase" ]
+| | | | ) [ "b3"."id" NOT NULL UNIQUE HASHCOL , "b3"."increase" NOT NULL as
"%3"."%3" ],
+| | | | project (
+| | | | | group by (
+| | | | | | join (
+| | | | | | | table("sys"."bidder") [ "bidder"."id" NOT NULL UNIQUE HASHCOL
as "b3a"."id", "bidder"."open_auction_id" NOT NULL as "b3a"."open_auction_id" ],
+| | | | | | | group by (
+| | | | | | | | project (
+| | | | | | | | | & REF 1
+| | | | | | | | ) [ "o"."open_auction_id" NOT NULL ]
+| | | | | | | ) [ "o"."open_auction_id" NOT NULL ] [ "o"."open_auction_id" NOT
NULL ]
+| | | | | | ) [ ("b3a"."open_auction_id" NOT NULL) = ("o"."open_auction_id"
NOT NULL UNIQUE) ]
+| | | | | ) [ "o"."open_auction_id" NOT NULL ] [ "sys"."min" no nil
("b3a"."id" NOT NULL HASHCOL ) NOT NULL as "%1"."%1", "o"."open_auction_id" NOT
NULL ]
+| | | | ) [ "o"."open_auction_id" NOT NULL UNIQUE, "%1"."%1" NOT NULL as
"%2"."%2" ]
+| | | ) [ ("b3"."id" NOT NULL UNIQUE HASHCOL ) = ("%2"."%2" NOT NULL) ]
+| | ) [ "%3"."%3" NOT NULL, "o"."open_auction_id" NOT NULL as "%7"."%7" ]
+| ) [ ("o"."open_auction_id" NOT NULL) * = ("%7"."%7" NOT NULL) ]
+) [ "o"."open_auction_id" NOT NULL, "b"."id" NOT NULL HASHCOL ,
"b"."open_auction_id" NOT NULL, "b"."date" NOT NULL, "b"."time" NOT NULL,
"b"."personref" NOT NULL, "b"."increase" NOT NULL, "%3"."%3" ]
project (
| select (
| | single project (
diff --git a/sql/test/Dependencies/Tests/dependency_DBobjects.test
b/sql/test/Dependencies/Tests/dependency_DBobjects.test
--- a/sql/test/Dependencies/Tests/dependency_DBobjects.test
+++ b/sql/test/Dependencies/Tests/dependency_DBobjects.test
@@ -361,9 +361,6 @@ id
get_merge_table_partition_expressions
DEP_FUNC
id
-get_merge_table_partition_expressions
-DEP_FUNC
-id
get_remote_table_expressions
DEP_FUNC
id
diff --git a/sql/test/Dependencies/Tests/dependency_owner_schema_3.test
b/sql/test/Dependencies/Tests/dependency_owner_schema_3.test
--- a/sql/test/Dependencies/Tests/dependency_owner_schema_3.test
+++ b/sql/test/Dependencies/Tests/dependency_owner_schema_3.test
@@ -1002,9 +1002,6 @@ id
get_merge_table_partition_expressions
DEP_FUNC
id
-get_merge_table_partition_expressions
-DEP_FUNC
-id
get_remote_table_expressions
DEP_FUNC
id
diff --git a/sql/test/emptydb/Tests/check.stable.out.int128
b/sql/test/emptydb/Tests/check.stable.out.int128
--- a/sql/test/emptydb/Tests/check.stable.out.int128
+++ b/sql/test/emptydb/Tests/check.stable.out.int128
@@ -3180,7 +3180,6 @@ select 'null in fkeys.delete_action', de
[ "column used by function", "sys", "columns", "name", "sys",
"get_merge_table_partition_expressions", "FUNCTION" ]
[ "column used by function", "sys", "table_partitions", "column_id",
"sys", "get_merge_table_partition_expressions", "FUNCTION" ]
[ "column used by function", "sys", "table_partitions", "expression",
"sys", "get_merge_table_partition_expressions", "FUNCTION" ]
-[ "column used by function", "sys", "table_partitions", "id", "sys",
"get_merge_table_partition_expressions", "FUNCTION" ]
[ "column used by function", "sys", "table_partitions", "table_id",
"sys", "get_merge_table_partition_expressions", "FUNCTION" ]
[ "column used by function", "sys", "table_partitions", "type", "sys",
"get_merge_table_partition_expressions", "FUNCTION" ]
[ "column used by function", "sys", "_tables", "id", "sys",
"get_remote_table_expressions", "FUNCTION" ]
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]