Skip to content

Optimized and MapJoin friendly Q16 #3962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 39 additions & 20 deletions ydb/library/benchmarks/queries/tpch/ydb/q16.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,61 @@
-- TPC TPC-H Parameter Substitution (Version 2.17.2 build 0)
-- using 1680793381 as a seed to the RNG

$join = (
$p = (
select
ps.ps_suppkey as ps_suppkey,
ps.ps_partkey as ps_partkey
p.p_brand as p_brand,
p.p_type as p_type,
p.p_size as p_size,
ps.ps_suppkey as ps_suppkey
from
`{path}part` as p
join
`{path}partsupp` as ps
left join
`{path}supplier` as w
on
w.s_suppkey = ps.ps_suppkey
where not (s_comment like "%Customer%Complaints%")
p.p_partkey = ps.ps_partkey
where
p.p_brand <> 'Brand#33'
and (not StartsWith(p.p_type, 'PROMO POLISHED'))
and (p.p_size = 20 or p.p_size = 27 or p.p_size = 11 or p.p_size = 45 or p.p_size = 40 or p.p_size = 41 or p.p_size = 34 or p.p_size = 36)
);

$s = (
select
s_suppkey
from
`{path}supplier`
where
s_comment like "%Customer%Complaints%"
);

$j = (
select
p.p_brand as p_brand,
p.p_type as p_type,
p.p_size as p_size,
count(distinct j.ps_suppkey) as supplier_cnt
p.ps_suppkey as ps_suppkey
from
$join as j
join
`{path}part` as p
$p as p
left only join
$s as s
on
p.p_partkey = j.ps_partkey
where
p.p_brand <> 'Brand#33'
and (not StartsWith(p.p_type, 'PROMO POLISHED'))
and (p.p_size = 20 or p.p_size = 27 or p.p_size = 11 or p.p_size = 45 or p.p_size = 40 or p.p_size = 41 or p.p_size = 34 or p.p_size = 36)
p.ps_suppkey = s.s_suppkey
);

select
j.p_brand as p_brand,
j.p_type as p_type,
j.p_size as p_size,
count(distinct j.ps_suppkey) as supplier_cnt
from
$j as j
group by
p.p_brand,
p.p_type,
p.p_size
j.p_brand,
j.p_type,
j.p_size
order by
supplier_cnt desc,
p_brand,
p_type,
p_size
;

59 changes: 39 additions & 20 deletions ydb/library/benchmarks/queries/tpch/yql/q16.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,61 @@
-- TPC TPC-H Parameter Substitution (Version 2.17.2 build 0)
-- using 1680793381 as a seed to the RNG

$join = (
$p = (
select
ps.ps_suppkey as ps_suppkey,
ps.ps_partkey as ps_partkey
p.p_brand as p_brand,
p.p_type as p_type,
p.p_size as p_size,
ps.ps_suppkey as ps_suppkey
from
{{part}} as p
join
{{partsupp}} as ps
left join
{{supplier}} as w
on
w.s_suppkey = ps.ps_suppkey
where not (s_comment like "%Customer%Complaints%")
p.p_partkey = ps.ps_partkey
where
p.p_brand <> 'Brand#33'
and (not StartsWith(p.p_type, 'PROMO POLISHED'))
and (p.p_size = 20 or p.p_size = 27 or p.p_size = 11 or p.p_size = 45 or p.p_size = 40 or p.p_size = 41 or p.p_size = 34 or p.p_size = 36)
);

$s = (
select
s_suppkey
from
{{supplier}}
where
s_comment like "%Customer%Complaints%"
);

$j = (
select
p.p_brand as p_brand,
p.p_type as p_type,
p.p_size as p_size,
count(distinct j.ps_suppkey) as supplier_cnt
p.ps_suppkey as ps_suppkey
from
$join as j
join
{{part}} as p
$p as p
left only join
$s as s
on
p.p_partkey = j.ps_partkey
where
p.p_brand <> 'Brand#33'
and (not StartsWith(p.p_type, 'PROMO POLISHED'))
and (p.p_size = 20 or p.p_size = 27 or p.p_size = 11 or p.p_size = 45 or p.p_size = 40 or p.p_size = 41 or p.p_size = 34 or p.p_size = 36)
p.ps_suppkey = s.s_suppkey
);

select
j.p_brand as p_brand,
j.p_type as p_type,
j.p_size as p_size,
count(distinct j.ps_suppkey) as supplier_cnt
from
$j as j
group by
p.p_brand,
p.p_type,
p.p_size
j.p_brand,
j.p_type,
j.p_size
order by
supplier_cnt desc,
p_brand,
p_type,
p_size
;

Loading