Skip to content

Commit

Permalink
tpc ds: manually optimize join order to workaround #7565 (#8163)
Browse files Browse the repository at this point in the history
  • Loading branch information
yumkam authored Aug 22, 2024
1 parent 32a5a69 commit 778f3e8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
5 changes: 3 additions & 2 deletions ydb/library/benchmarks/queries/tpcds/yql/q18.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% include 'header.sql.jinja' %}

-- TODO this commit should be reverted upon proper fix for https://github.com/ydb-platform/ydb/issues/7565
-- NB: Subquerys
-- start query 1 in stream 0 using template query18.tpl and seed 1978355063
select item.i_item_id,
Expand All @@ -15,10 +16,10 @@ select item.i_item_id,
avg( cast(cd1.cd_dep_count as float)) agg7
from {{catalog_sales}} as catalog_sales
cross join {{customer_demographics}} cd1
cross join {{customer_demographics}} cd2
cross join {{date_dim}} as date_dim
cross join {{customer}} as customer
cross join {{customer_demographics}} cd2
cross join {{customer_address}} as customer_address
cross join {{date_dim}} as date_dim
cross join {{item}} as item
where cs_sold_date_sk = d_date_sk and
cs_item_sk = i_item_sk and
Expand Down
3 changes: 2 additions & 1 deletion ydb/library/benchmarks/queries/tpcds/yql/q30.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% include 'header.sql.jinja' %}

-- TODO this commit should be reverted upon proper fix for https://github.com/ydb-platform/ydb/issues/7565
-- NB: Subquerys
$customer_total_return =
(select web_returns.wr_returning_customer_sk as ctr_customer_sk
Expand All @@ -25,8 +26,8 @@ $avg_total_return_by_state =
,c_last_review_date,ctr_total_return
from $customer_total_return ctr1
join $avg_total_return_by_state ctr2 on ctr1.ctr_state = ctr2.ctr_state
cross join {{customer_address}} as customer_address
cross join {{customer}} as customer
cross join {{customer_address}} as customer_address
where ctr1.ctr_total_return > $z1_2_35*ctr2.avg_return
and ca_address_sk = c_current_addr_sk
and ca_state = 'GA'
Expand Down
9 changes: 5 additions & 4 deletions ydb/library/benchmarks/queries/tpcds/yql/q64.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% include 'header.sql.jinja' %}

-- TODO this commit should be reverted upon proper fix for https://github.com/ydb-platform/ydb/issues/7565
-- NB: Subquerys
$cs_ui =
(select catalog_sales.cs_item_sk cs_item_sk
Expand Down Expand Up @@ -31,17 +32,17 @@ $cross_sales =
,sum(ss_list_price) s2
,sum(ss_coupon_amt) s3
FROM {{store_sales}} as store_sales
cross join {{customer_demographics}} cd1
cross join {{household_demographics}} hd1
cross join {{store_returns}} as store_returns
cross join $cs_ui cs_ui
cross join {{date_dim}} d1
cross join {{date_dim}} d2
cross join {{date_dim}} d3
cross join {{store}} as store
cross join {{customer}} as customer
cross join {{customer_demographics}} cd1
cross join {{date_dim}} d2
cross join {{date_dim}} d3
cross join {{customer_demographics}} cd2
cross join {{promotion}} as promotion
cross join {{household_demographics}} hd1
cross join {{household_demographics}} hd2
cross join {{customer_address}} ad1
cross join {{customer_address}} ad2
Expand Down
2 changes: 2 additions & 0 deletions ydb/library/benchmarks/queries/tpcds/yql/q65.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% include 'header.sql.jinja' %}

-- TODO this commit should be reverted upon proper fix for https://github.com/ydb-platform/ydb/issues/7565
-- NB: Subquerys
-- start query 1 in stream 0 using template query65.tpl and seed 1819994127
select
Expand Down Expand Up @@ -28,6 +29,7 @@ select
where sb.ss_store_sk = sc.ss_store_sk and
sc.revenue <= $z0_1_35 * sb.ave and
s_store_sk = sc.ss_store_sk and
s_store_sk = sb.ss_store_sk and
i_item_sk = sc.ss_item_sk
order by s_store_name, i_item_desc
, i_wholesale_cost, sc.revenue, i_current_price
Expand Down
3 changes: 2 additions & 1 deletion ydb/library/benchmarks/queries/tpcds/yql/q81.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% include 'header.sql.jinja' %}

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

0 comments on commit 778f3e8

Please sign in to comment.