From 45dbd9be2939afcab3584ba9ab92b446d08df326 Mon Sep 17 00:00:00 2001 From: perdelt Date: Wed, 13 Nov 2024 16:06:05 +0100 Subject: [PATCH] TPC-DS: Queries updated --- experiments/tpcds/queries-tpcds.config | 177 ++++++++++++++----------- 1 file changed, 99 insertions(+), 78 deletions(-) diff --git a/experiments/tpcds/queries-tpcds.config b/experiments/tpcds/queries-tpcds.config index da5ca6d8..3cb48f3a 100644 --- a/experiments/tpcds/queries-tpcds.config +++ b/experiments/tpcds/queries-tpcds.config @@ -460,32 +460,33 @@ , sum(profit) as profit from (select 'store channel' as channel - , 'store' || s_store_id as id + , concat('store', s_store_id) as id , sales , returns_angepasst , (profit - profit_loss) as profit from ssr union all select 'catalog channel' as channel - , 'catalog_page' || cp_catalog_page_id as id + , concat('catalog_page', cp_catalog_page_id) as id , sales , returns_angepasst , (profit - profit_loss) as profit from csr union all select 'web channel' as channel - , 'web_site' || web_site_id as id + , concat('web_site', web_site_id) as id , sales , returns_angepasst , (profit - profit_loss) as profit from wsr ) x group by channel, id with rollup - order by channel - ,id + order by channel is not null, channel + ,id is not null, id limit 100""", 'DBMS': { - 'MariaDB': """ with ssr as + 'MariaDB': """with total as ( + with ssr as (select s_store_id, sum(sales_price) as sales, sum(profit) as profit, @@ -586,28 +587,32 @@ , sum(profit) as profit from (select 'store channel' as channel - , 'store' || s_store_id as id + , concat('store', s_store_id) as id , sales , returns_angepasst , (profit - profit_loss) as profit from ssr union all select 'catalog channel' as channel - , 'catalog_page' || cp_catalog_page_id as id + , concat('catalog_page', cp_catalog_page_id) as id , sales , returns_angepasst , (profit - profit_loss) as profit from csr union all select 'web channel' as channel - , 'web_site' || web_site_id as id + , concat('web_site', web_site_id) as id , sales , returns_angepasst , (profit - profit_loss) as profit from wsr ) x group by channel, id with rollup - limit 100""", + ) + select * from total + order by channel is not null, channel + ,id is not null, id + limit 100""", 'MonetDB': """ with ssr as (select s_store_id, sum(sales_price) as sales, @@ -855,8 +860,8 @@ from wsr ) x group by rollup(channel, id) - order by channel - ,id + order by channel is not null, channel + ,id is not null, id limit 100""", 'Exasol': """ with ssr as (select s_store_id, @@ -3135,7 +3140,7 @@ and cs_sold_date_sk = d_date_sk and d_qoy = {QOY} and d_year = {YEAR} group by ca_zip - order by ca_zip + order by ca_zip is not null, ca_zip limit 100""", 'parameter': { @@ -3334,10 +3339,10 @@ d_year = {YEAR} and ca_state in ('{STATE1}','{STATE2}','{STATE3}','{STATE4}','{STATE5}','{STATE6}','{STATE7}') group by i_item_id, ca_country, ca_state, ca_county with rollup - order by ca_country, - ca_state, - ca_county, - i_item_id + order by ca_country is not null, ca_country, + ca_state is not null, ca_state, + ca_county is not null, ca_county, + i_item_id is not null, i_item_id limit 100""", 'DBMS': { 'PostgreSQL': """select i_item_id, @@ -3365,10 +3370,10 @@ d_year = {YEAR} and ca_state in ('{STATE1}','{STATE2}','{STATE3}','{STATE4}','{STATE5}','{STATE6}','{STATE7}') group by rollup(i_item_id, ca_country, ca_state, ca_county) - order by ca_country, - ca_state, - ca_county, - i_item_id + order by ca_country is not null, ca_country, + ca_state is not null, ca_state, + ca_county is not null, ca_county, + i_item_id is not null, i_item_id limit 100""", 'MonetDB': """select i_item_id, ca_country, @@ -3395,12 +3400,12 @@ d_year = {YEAR} and ca_state in ('{STATE1}','{STATE2}','{STATE3}','{STATE4}','{STATE5}','{STATE6}','{STATE7}') group by rollup(i_item_id, ca_country, ca_state, ca_county) - order by ca_country, - ca_state, - ca_county, - i_item_id + order by ca_country is not null, ca_country, + ca_state is not null, ca_state, + ca_county is not null, ca_county, + i_item_id is not null, i_item_id limit 100""", - 'MariaDB': """ select i_item_id, + 'MariaDB': """with total as (select i_item_id, ca_country, ca_state, ca_county, @@ -3424,7 +3429,12 @@ c_birth_month in ({MONTH1},{MONTH2},{MONTH3},{MONTH4},{MONTH5},{MONTH6}) and d_year = {YEAR} and ca_state in ('{STATE1}','{STATE2}','{STATE3}','{STATE4}','{STATE5}','{STATE6}','{STATE7}') - group by i_item_id, ca_country, ca_state, ca_county with rollup + group by i_item_id, ca_country, ca_state, ca_county with rollup) + select * from total + order by ca_country is not null, ca_country, + ca_state is not null, ca_state, + ca_county is not null, ca_county, + i_item_id is not null, i_item_id limit 100""" }, 'parameter': @@ -3618,8 +3628,8 @@ then inv_after / inv_before else null end) between 2.0/3.0 and 3.0/2.0 - order by w_warehouse_name - ,i_item_id + order by w_warehouse_name is not null, w_warehouse_name + ,i_item_id is not null, i_item_id, inv_before, inv_after limit 100""", 'parameter': { @@ -3673,10 +3683,10 @@ ,i_brand ,i_class ,i_category with rollup - order by qoh, i_product_name, i_brand, i_class, i_category + order by qoh is not null, qoh, i_product_name is not null, i_product_name, i_brand is not null, i_brand, i_class is not null, i_class, i_category is not null, i_category limit 100""", 'DBMS': { - 'MariaDB': """select i_product_name + 'MariaDB': """with total as (select i_product_name ,i_brand ,i_class ,i_category @@ -3690,7 +3700,9 @@ group by i_product_name ,i_brand ,i_class - ,i_category with rollup + ,i_category with rollup) + select * from total + order by qoh is not null, qoh, i_product_name is not null, i_product_name, i_brand is not null, i_brand, i_class is not null, i_class, i_category is not null, i_category limit 100""", 'MonetDB': """select i_product_name ,i_brand @@ -3707,7 +3719,7 @@ ,i_brand ,i_class ,i_category) - order by qoh, i_product_name, i_brand, i_class, i_category + order by avg(inv_quantity_on_hand) is not null, avg(inv_quantity_on_hand), i_product_name is not null, i_product_name, i_brand is not null, i_brand, i_class is not null, i_class, i_category is not null, i_category limit 100""", 'PostgreSQL': """select i_product_name ,i_brand @@ -3724,7 +3736,7 @@ ,i_brand ,i_class ,i_category) - order by qoh, i_product_name, i_brand, i_class, i_category + order by avg(inv_quantity_on_hand) is not null, avg(inv_quantity_on_hand), i_product_name is not null, i_product_name, i_brand is not null, i_brand, i_class is not null, i_class, i_category is not null, i_category limit 100""" }, 'parameter': @@ -4907,12 +4919,12 @@ cd_dep_count, cd_dep_employed_count, cd_dep_college_count - order by ca_state, - cd_gender, - cd_marital_status, - cd_dep_count, - cd_dep_employed_count, - cd_dep_college_count + order by ca_state is not null, ca_state, + cd_gender is not null, cd_gender, + cd_marital_status is not null, cd_marital_status, + cd_dep_count is not null, cd_dep_count, + cd_dep_employed_count is not null, cd_dep_employed_count, + cd_dep_college_count is not null, cd_dep_college_count limit 100""", 'parameter': { @@ -4983,11 +4995,11 @@ limit 100""", 'DBMS': { 'MariaDB': """ SELECT + gross_margin, i_category, i_class, CASE WHEN i_category IS NULL THEN 1 ELSE 0 END + CASE WHEN i_class IS NULL THEN 1 ELSE 0 END AS lochierarchy, - gross_margin, RANK() OVER ( PARTITION BY lochierarchy, CASE WHEN i_class IS NOT NULL THEN i_category END @@ -7168,8 +7180,8 @@ LIMIT 100""" }, { 'title': "TPC-DS Q62", - 'query': """ select - substr(w_warehouse_name,1,20) + 'query': """with total as (select + substr(w_warehouse_name,1,20) as warehouse_name ,sm_type ,web_name ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" @@ -7195,8 +7207,9 @@ LIMIT 100""" group by substr(w_warehouse_name,1,20) ,sm_type - ,web_name - order by substr(w_warehouse_name,1,20) + ,web_name) + select * from total + order by warehouse_name is not null, warehouse_name ,sm_type ,web_name limit 100""", @@ -7796,11 +7809,11 @@ LIMIT 100""" and d_month_seq between {DMS} and {DMS}+11 group by i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id with rollup )dw1) dw2 where rk <= 100 - order by i_category - ,i_class - ,i_brand - ,i_product_name - ,d_year + order by i_category is not null, i_category + ,i_class is not null, i_class + ,i_brand is not null, i_brand + ,i_product_name is not null, i_product_name + ,d_year is not null, d_year ,d_qoy ,d_moy ,s_store_id @@ -7839,11 +7852,11 @@ LIMIT 100""" and d_month_seq between {DMS} and {DMS}+11 group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id) )dw1) dw2 where rk <= 100 - order by i_category - ,i_class - ,i_brand - ,i_product_name - ,d_year + order by i_category is not null, i_category + ,i_class is not null, i_class + ,i_brand is not null, i_brand + ,i_product_name is not null, i_product_name + ,d_year is not null, d_year ,d_qoy ,d_moy ,s_store_id @@ -7881,11 +7894,11 @@ LIMIT 100""" and d_month_seq between {DMS} and {DMS}+11 group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id) )dw1) dw2 where rk <= 100 - order by i_category - ,i_class - ,i_brand - ,i_product_name - ,d_year + order by i_category is not null, i_category + ,i_class is not null, i_class + ,i_brand is not null, i_brand + ,i_product_name is not null, i_product_name + ,d_year is not null, d_year ,d_qoy ,d_moy ,s_store_id @@ -8488,7 +8501,7 @@ LIMIT 100""" and d1.d_year = {YEAR} and cd_marital_status = '{MS}' group by i_item_desc,w_warehouse_name,d1.d_week_seq - order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq + order by total_cnt desc, i_item_desc is not null, i_item_desc, w_warehouse_name is not null, w_warehouse_name, d_week_seq limit 100""", 'parameter': { @@ -9600,7 +9613,7 @@ LIMIT 100""" { 'title': "TPC-DS Q79", 'query': """ select - c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit + c_last_name,c_first_name,substr(s_city,1,30) city,ss_ticket_number,amt,profit from (select ss_ticket_number ,ss_customer_sk @@ -9617,7 +9630,7 @@ LIMIT 100""" and store.s_number_employees between 200 and 295 group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer where ss_customer_sk = c_customer_sk - order by c_last_name,c_first_name,substr(s_city,1,30), profit + order by c_last_name is not null, c_last_name, c_first_name is not null, c_first_name, substr(s_city,1,30) is not null, substr(s_city,1,30), profit is not null, profit limit 100""", 'parameter': { @@ -9746,11 +9759,11 @@ LIMIT 100""" from wsr ) x group by channel, id with rollup - order by channel - ,id + order by channel is not null, channel + ,id is not null, id limit 100""", 'DBMS': { - 'MariaDB': """with ssr as + 'MariaDB': """with total as (with ssr as (select s_store_id as store_id, sum(ss_ext_sales_price) as sales, sum(coalesce(sr_return_amt, 0)) as returns_angepasst, @@ -9839,7 +9852,10 @@ LIMIT 100""" , profit from wsr ) x - group by channel, id with rollup + group by channel, id with rollup) + select * from total + order by channel is not null, channel + ,id is not null, id limit 100""", 'MonetDB': """with ssr as (select s_store_id as store_id, @@ -9931,8 +9947,8 @@ LIMIT 100""" from wsr ) x group by rollup(channel, id) - order by channel - ,id + order by channel is not null, channel + ,id is not null, id limit 100""", 'PostgreSQL': """with ssr as (select s_store_id as store_id, @@ -10024,8 +10040,8 @@ LIMIT 100""" from wsr ) x group by rollup(channel, id) - order by channel - ,id + order by channel is not null, channel + ,id is not null, id limit 100""", 'Exasol': """with ssr as (select s_store_id as store_id, @@ -10418,11 +10434,11 @@ LIMIT 100""" group by i_item_id) select sr_items.item_id ,sr_item_qty - ,sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 sr_dev + ,100.0*sr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 sr_dev ,cr_item_qty - ,cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 cr_dev + ,100.0*cr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 cr_dev ,wr_item_qty - ,wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 * 100 wr_dev + ,100.0*wr_item_qty/(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 wr_dev ,(sr_item_qty+cr_item_qty+wr_item_qty)/3.0 average from sr_items ,cr_items @@ -10669,7 +10685,7 @@ LIMIT 100""" ,rank() over ( partition by grouping(i_category)+grouping(i_class), case when grouping(i_class) = 0 then i_category end - order by sum(ws_net_paid) desc) as rank_within_parent + order by sum(ws_net_paid) is not null desc, sum(ws_net_paid) desc) as rank_within_parent from web_sales ,date_dim d1 @@ -10681,6 +10697,7 @@ LIMIT 100""" group by i_category,i_class with rollup order by lochierarchy desc, + case when lochierarchy = 0 then i_category is not null end, case when lochierarchy = 0 then i_category end, rank_within_parent limit 100""", @@ -10710,6 +10727,7 @@ FROM ( ) AS aggregated_data ORDER BY lochierarchy DESC, + CASE WHEN lochierarchy = 0 THEN i_category is not null END, CASE WHEN lochierarchy = 0 THEN i_category END, rank_within_parent LIMIT 100""", @@ -10736,6 +10754,7 @@ LIMIT 100""", select * from tmp order by lochierarchy desc, + case when lochierarchy = 0 then i_category is not null end, case when lochierarchy = 0 then i_category end, rank_within_parent limit 100""", @@ -10759,6 +10778,7 @@ LIMIT 100""", group by rollup(i_category,i_class) order by lochierarchy desc, + case when grouping(i_category)+grouping(i_class) = 0 then i_category is not null end, case when grouping(i_category)+grouping(i_class) = 0 then i_category end, rank_within_parent limit 100""", @@ -11265,7 +11285,7 @@ LIMIT 100""", }, { 'title': "TPC-DS Q93", - 'query': """ select ss_customer_sk + 'query': """with total as (select ss_customer_sk ,sum(act_sales) sumsales from (select ss_item_sk ,ss_ticket_number @@ -11277,8 +11297,9 @@ LIMIT 100""", ,reason where sr_reason_sk = r_reason_sk and r_reason_desc = '{REASON}') t - group by ss_customer_sk - order by sumsales, ss_customer_sk + group by ss_customer_sk) + select * from total + order by sumsales is not null, sumsales, ss_customer_sk limit 100""", 'parameter': {