Skip to content

Commit 778f3e8

Browse files
authored
tpc ds: manually optimize join order to workaround #7565 (#8163)
1 parent 32a5a69 commit 778f3e8

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

ydb/library/benchmarks/queries/tpcds/yql/q18.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% include 'header.sql.jinja' %}
22

3+
-- TODO this commit should be reverted upon proper fix for https://github.com/ydb-platform/ydb/issues/7565
34
-- NB: Subquerys
45
-- start query 1 in stream 0 using template query18.tpl and seed 1978355063
56
select item.i_item_id,
@@ -15,10 +16,10 @@ select item.i_item_id,
1516
avg( cast(cd1.cd_dep_count as float)) agg7
1617
from {{catalog_sales}} as catalog_sales
1718
cross join {{customer_demographics}} cd1
18-
cross join {{customer_demographics}} cd2
19+
cross join {{date_dim}} as date_dim
1920
cross join {{customer}} as customer
21+
cross join {{customer_demographics}} cd2
2022
cross join {{customer_address}} as customer_address
21-
cross join {{date_dim}} as date_dim
2223
cross join {{item}} as item
2324
where cs_sold_date_sk = d_date_sk and
2425
cs_item_sk = i_item_sk and

ydb/library/benchmarks/queries/tpcds/yql/q30.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% include 'header.sql.jinja' %}
22

3+
-- TODO this commit should be reverted upon proper fix for https://github.com/ydb-platform/ydb/issues/7565
34
-- NB: Subquerys
45
$customer_total_return =
56
(select web_returns.wr_returning_customer_sk as ctr_customer_sk
@@ -25,8 +26,8 @@ $avg_total_return_by_state =
2526
,c_last_review_date,ctr_total_return
2627
from $customer_total_return ctr1
2728
join $avg_total_return_by_state ctr2 on ctr1.ctr_state = ctr2.ctr_state
28-
cross join {{customer_address}} as customer_address
2929
cross join {{customer}} as customer
30+
cross join {{customer_address}} as customer_address
3031
where ctr1.ctr_total_return > $z1_2_35*ctr2.avg_return
3132
and ca_address_sk = c_current_addr_sk
3233
and ca_state = 'GA'

ydb/library/benchmarks/queries/tpcds/yql/q64.sql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% include 'header.sql.jinja' %}
22

3+
-- TODO this commit should be reverted upon proper fix for https://github.com/ydb-platform/ydb/issues/7565
34
-- NB: Subquerys
45
$cs_ui =
56
(select catalog_sales.cs_item_sk cs_item_sk
@@ -31,17 +32,17 @@ $cross_sales =
3132
,sum(ss_list_price) s2
3233
,sum(ss_coupon_amt) s3
3334
FROM {{store_sales}} as store_sales
35+
cross join {{customer_demographics}} cd1
36+
cross join {{household_demographics}} hd1
3437
cross join {{store_returns}} as store_returns
3538
cross join $cs_ui cs_ui
3639
cross join {{date_dim}} d1
37-
cross join {{date_dim}} d2
38-
cross join {{date_dim}} d3
3940
cross join {{store}} as store
4041
cross join {{customer}} as customer
41-
cross join {{customer_demographics}} cd1
42+
cross join {{date_dim}} d2
43+
cross join {{date_dim}} d3
4244
cross join {{customer_demographics}} cd2
4345
cross join {{promotion}} as promotion
44-
cross join {{household_demographics}} hd1
4546
cross join {{household_demographics}} hd2
4647
cross join {{customer_address}} ad1
4748
cross join {{customer_address}} ad2

ydb/library/benchmarks/queries/tpcds/yql/q65.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% include 'header.sql.jinja' %}
22

3+
-- TODO this commit should be reverted upon proper fix for https://github.com/ydb-platform/ydb/issues/7565
34
-- NB: Subquerys
45
-- start query 1 in stream 0 using template query65.tpl and seed 1819994127
56
select
@@ -28,6 +29,7 @@ select
2829
where sb.ss_store_sk = sc.ss_store_sk and
2930
sc.revenue <= $z0_1_35 * sb.ave and
3031
s_store_sk = sc.ss_store_sk and
32+
s_store_sk = sb.ss_store_sk and
3133
i_item_sk = sc.ss_item_sk
3234
order by s_store_name, i_item_desc
3335
, i_wholesale_cost, sc.revenue, i_current_price

ydb/library/benchmarks/queries/tpcds/yql/q81.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% include 'header.sql.jinja' %}
22

3+
-- TODO this commit should be reverted upon proper fix for https://github.com/ydb-platform/ydb/issues/7565
34
-- NB: Subquerys
45
$customer_total_return =
56
(select catalog_returns.cr_returning_customer_sk as ctr_customer_sk
@@ -20,8 +21,8 @@ $avg_ctr_total_return = (select ctr_state, avg(ctr_total_return) as ctr_total_re
2021
,ca_location_type,ctr1.ctr_total_return
2122
from $customer_total_return ctr1
2223
join $avg_ctr_total_return ctr2 on (ctr1.ctr_state = ctr2.ctr_state)
23-
cross join {{customer_address}} as customer_address
2424
cross join {{customer}} as customer
25+
cross join {{customer_address}} as customer_address
2526
where ctr1.ctr_total_return > ctr2.ctr_total_return*$z1_2_35
2627
and ca_address_sk = c_current_addr_sk
2728
and ca_state = 'TX'

0 commit comments

Comments
 (0)