├── .gitmodules ├── README.md ├── blazingsql ├── .gitignore ├── execute_query.py ├── install_blazingsql.sh ├── run_query.py ├── sql │ ├── aggregate.sql │ ├── join.sql │ ├── sample.sql │ ├── scan.sql │ ├── ssb_1col.sql │ ├── ssb_allcol.sql │ ├── ssb_q11.sql │ ├── ssb_q12.sql │ ├── ssb_q13.sql │ ├── ssb_q21.sql │ ├── ssb_q22.sql │ ├── ssb_q23.sql │ ├── ssb_q31.sql │ ├── ssb_q32.sql │ ├── ssb_q33.sql │ ├── ssb_q34.sql │ ├── ssb_q41.sql │ ├── ssb_q42.sql │ └── ssb_q43.sql └── table │ ├── aggregate_1gb.txt │ ├── join_100mb_1gb.txt │ ├── join_1gb_1gb.txt │ ├── join_test.txt │ ├── sample.txt │ ├── scan_100mb.txt │ ├── scan_1gb.txt │ └── ssb.txt ├── characterization_script ├── run_blazingsql.sh ├── run_crystal.sh └── run_heavydb.sh ├── concurrency_script ├── blazingsql_execute_query.py ├── blazingsql_part_mig.py ├── crystal_part_mig.py ├── crystal_part_mps.py └── heavydb_part_mig.py ├── crystal ├── crystal_src │ ├── .gitignore │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── crystal │ │ ├── crystal.cuh │ │ ├── join.cuh │ │ ├── load.cuh │ │ ├── pred.cuh │ │ ├── profiler.cuh │ │ ├── reduce.cuh │ │ ├── store.cuh │ │ └── term.cuh │ ├── gpudb-perf.nsys-rep │ ├── src │ │ ├── ops │ │ │ ├── aggregate.cu │ │ │ ├── join.cu │ │ │ ├── project.cu │ │ │ └── utils │ │ │ │ ├── generator.h │ │ │ │ └── gpu_utils.h │ │ └── ssb │ │ │ ├── all.cu │ │ │ ├── gpu_utils.h │ │ │ ├── q11.cu │ │ │ ├── q12.cu │ │ │ ├── q13.cu │ │ │ ├── q21.cu │ │ │ ├── q22.cu │ │ │ ├── q23.cu │ │ │ ├── q31.cu │ │ │ ├── q32.cu │ │ │ ├── q33.cu │ │ │ ├── q34.cu │ │ │ ├── q41.cu │ │ │ ├── q42.cu │ │ │ ├── q43.cu │ │ │ ├── qcopy.cu │ │ │ └── ssb_utils.h │ └── test │ │ ├── ssb │ │ ├── .gitignore │ │ ├── SSB.md │ │ ├── dbgen │ │ │ ├── BUGS │ │ │ ├── CHANGES │ │ │ ├── HISTORY │ │ │ ├── PORTING.NOTES │ │ │ ├── README │ │ │ ├── TPCH_README │ │ │ ├── bcd2.c │ │ │ ├── bcd2.h │ │ │ ├── bm_utils.c │ │ │ ├── build.c │ │ │ ├── config.h │ │ │ ├── convert.py │ │ │ ├── debug.txt │ │ │ ├── dists.dss │ │ │ ├── driver.c │ │ │ ├── dss.ddl │ │ │ ├── dss.h │ │ │ ├── dss.ri │ │ │ ├── dsstypes.h │ │ │ ├── history.html │ │ │ ├── load_stub.c │ │ │ ├── makefile │ │ │ ├── makefile.suite │ │ │ ├── makefile_win │ │ │ ├── permute.c │ │ │ ├── permute.h │ │ │ ├── print.c │ │ │ ├── qgen.c │ │ │ ├── rnd.c │ │ │ ├── rnd.h │ │ │ ├── shared.h │ │ │ ├── speed_seed.c │ │ │ ├── tags │ │ │ ├── text.c │ │ │ ├── tpcd.h │ │ │ └── varsub.c │ │ └── queries │ │ │ ├── original │ │ │ ├── load.sql │ │ │ ├── q11.sql │ │ │ ├── q12.sql │ │ │ ├── q13.sql │ │ │ ├── q21.sql │ │ │ ├── q22.sql │ │ │ ├── q23.sql │ │ │ ├── q31.sql │ │ │ ├── q32.sql │ │ │ ├── q33.sql │ │ │ ├── q34.sql │ │ │ ├── q41.sql │ │ │ ├── q42.sql │ │ │ ├── q43.sql │ │ │ └── schema.sql │ │ │ └── transformed │ │ │ ├── load.sql │ │ │ ├── p1.sql │ │ │ ├── q11.sql │ │ │ ├── q12.sql │ │ │ ├── q13.sql │ │ │ ├── q21.sql │ │ │ ├── q22.sql │ │ │ ├── q23.sql │ │ │ ├── q31.sql │ │ │ ├── q32.sql │ │ │ ├── q33.sql │ │ │ ├── q34.sql │ │ │ ├── q41.sql │ │ │ ├── q42.sql │ │ │ ├── q43.sql │ │ │ ├── schema.sql │ │ │ └── schema_no_pk.sql │ │ └── util.py ├── readme.md └── run_query.py ├── data ├── Makefile ├── convert_all_to_parquet.py ├── convert_to_parquet.py ├── generate_data.cpp ├── generate_ssbm.py └── ssbm │ ├── conversion │ ├── .metadata │ ├── Makefile │ ├── columnSort.c │ ├── convert.py │ ├── convert_old.py │ ├── dict.c │ ├── include │ │ ├── common.h │ │ └── schema.h │ ├── load.c │ ├── load_modified.c │ ├── loader │ ├── rle.c │ └── soa.c │ └── ssbm_src │ ├── .gitignore │ ├── BUGS │ ├── CHANGES │ ├── HISTORY │ ├── PORTING.NOTES │ ├── README │ ├── TPCH_README │ ├── bcd2.c │ ├── bcd2.h │ ├── bm_utils.c │ ├── build.c │ ├── config.h │ ├── dists.dss │ ├── driver.c │ ├── dss.ddl │ ├── dss.h │ ├── dss.ri │ ├── dsstypes.h │ ├── history.html │ ├── load_stub.c │ ├── makefile │ ├── makefile.suite │ ├── makefile_win │ ├── permute.c │ ├── permute.h │ ├── print.c │ ├── qgen.c │ ├── rnd.c │ ├── rnd.h │ ├── shared.h │ ├── speed_seed.c │ ├── text.c │ ├── tpcd.h │ └── varsub.c ├── heavydb ├── .gitignore ├── heavydb.conf ├── heavydb_part0.conf ├── heavydb_part1.conf ├── heavydb_part2.conf ├── heavydb_part3.conf ├── heavydb_part4.conf ├── heavydb_part5.conf ├── heavydb_part6.conf ├── install_heavydb.sh ├── prepare_data_dir.sh ├── readme.md ├── run_query.py └── sql │ ├── aggregate_1gb_cached.sql │ ├── aggregate_1gb_uncached.sql │ ├── join_100mb_1gb_cached.sql │ ├── join_100mb_1gb_uncached.sql │ ├── join_1gb_1gb_cached.sql │ ├── join_1gb_1gb_uncached.sql │ ├── sample.sql │ ├── scan_100mb_cached.sql │ ├── scan_100mb_uncached.sql │ ├── scan_1gb_cached.sql │ ├── scan_1gb_uncached.sql │ ├── ssb_1col.sql │ ├── ssb_allcol.sql │ ├── ssb_create_table.sql │ ├── ssb_load_table.sql │ ├── ssb_q11_cached.sql │ ├── ssb_q11_uncached.sql │ ├── ssb_q12_cached.sql │ ├── ssb_q12_uncached.sql │ ├── ssb_q13_cached.sql │ ├── ssb_q13_uncached.sql │ ├── ssb_q21_cached.sql │ ├── ssb_q21_uncached.sql │ ├── ssb_q22_cached.sql │ ├── ssb_q22_uncached.sql │ ├── ssb_q23_cached.sql │ ├── ssb_q23_uncached.sql │ ├── ssb_q31_cached.sql │ ├── ssb_q31_uncached.sql │ ├── ssb_q32_cached.sql │ ├── ssb_q32_uncached.sql │ ├── ssb_q33_cached.sql │ ├── ssb_q33_uncached.sql │ ├── ssb_q34_cached.sql │ ├── ssb_q34_uncached.sql │ ├── ssb_q41_cached.sql │ ├── ssb_q41_uncached.sql │ ├── ssb_q42_cached.sql │ ├── ssb_q42_uncached.sql │ ├── ssb_q43_cached.sql │ └── ssb_q43_uncached.sql ├── report_parser └── ncu_parser.py ├── stats ├── flush_ncu_csv.py └── ncu_export.py └── utility ├── counter_config.py ├── ncu_profiler.py └── profiler_logger.py /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "crystal/crystal-opt_src"] 2 | path = crystal/crystal-opt_src 3 | url = git@github.com:jiashenC/crystal-opt.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /blazingsql/.gitignore: -------------------------------------------------------------------------------- 1 | .local 2 | -------------------------------------------------------------------------------- /blazingsql/execute_query.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | os.environ["CONDA_PREFIX"] = os.path.join( 4 | os.path.dirname(os.path.abspath(__file__)), 5 | ".local/miniconda3/envs/bsql", 6 | ) 7 | 8 | import time 9 | import pandas as pd 10 | import argparse 11 | import subprocess as subp 12 | 13 | from blazingsql import BlazingContext 14 | 15 | from utility.profiler_logger import LOGGER 16 | 17 | 18 | def main(): 19 | parser = argparse.ArgumentParser() 20 | parser.add_argument( 21 | "--table", type=str, required=True, help="Table creation." 22 | ) 23 | parser.add_argument("--sql", type=str, required=True, help="SQL query.") 24 | parser.add_argument( 25 | "--warm-sql", type=str, default=None, help="Warmup SQL query." 26 | ) 27 | parser.add_argument( 28 | "--sf", type=int, default=1, help="Scale factor for benchmarking." 29 | ) 30 | parser.add_argument( 31 | "--iter", type=int, default=1, help="Number of iterations." 32 | ) 33 | args = parser.parse_args() 34 | 35 | config = { 36 | "BLAZING_LOGGING_DIRECTORY": "./.log/blazingsql_log/", 37 | "BLAZING_LOCAL_LOGGING_DIRECTORY": "./.log/blazingsql_log/", 38 | } 39 | 40 | bc = BlazingContext(config_options=config) 41 | 42 | # table drop and creation 43 | LOGGER.debug("Drop and create tables") 44 | table_list = [] 45 | with open(args.table) as f: 46 | for line in f.read().splitlines(): 47 | table_list.append(tuple(line.split(","))) 48 | 49 | for i, (tb, src) in enumerate(table_list): 50 | if tb in bc.list_tables(): 51 | bc.drop_table(tb) 52 | LOGGER.debug(f"Create table: {tb} -- {src}") 53 | src = src.replace("[sfph]", str(args.sf)) 54 | src_df = pd.read_parquet(src) 55 | bc.create_table(tb, src_df) 56 | 57 | cur_table = ",".join(bc.list_tables()) 58 | LOGGER.debug(f"Table: {cur_table}") 59 | 60 | if args.warm_sql is not None: 61 | LOGGER.debug("Parse warmup SQL query") 62 | with open(args.sql) as f: 63 | warm_sql = f.read().replace("\n", " ").rstrip() 64 | warm_sql_list = warm_sql.split(";")[:-1] 65 | 66 | for sql in warm_sql_list: 67 | LOGGER.debug(f"Warmup system with execution {sql}") 68 | _ = bc.sql(sql) 69 | 70 | time.sleep(1) 71 | 72 | # execute sql 73 | LOGGER.debug("Parse SQL query") 74 | with open(args.sql) as f: 75 | sql = f.read().replace("\n", " ").rstrip() 76 | sql_list = sql.split(";")[:-1] 77 | 78 | time.sleep(1) 79 | 80 | for _ in range(args.iter): 81 | st = time.perf_counter() 82 | for sql in sql_list: 83 | LOGGER.debug(f"Execute: {sql}") 84 | _ = bc.sql(sql) 85 | print(f"Execution time: {(time.perf_counter() - st) * 1000:.3f} ms") 86 | 87 | time.sleep(1) 88 | 89 | 90 | if __name__ == "__main__": 91 | main() 92 | -------------------------------------------------------------------------------- /blazingsql/install_blazingsql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export BLAZINGSQL_ROOT="./blazingsql" 4 | 5 | # install miniconda first 6 | $BLAZINGSQL_ROOT/.local/miniconda3/bin/python3 --version 7 | retcode=$? 8 | if [ $retcode -ne 0 ]; then 9 | wget -P $BLAZINGSQL_ROOT https://repo.anaconda.com/miniconda/Miniconda3-py38_4.12.0-Linux-x86_64.sh 10 | mkdir $BLAZINGSQL_ROOT/.local 11 | bash $BLAZINGSQL_ROOT/Miniconda3-py38_4.12.0-Linux-x86_64.sh -b -p $BLAZINGSQL_ROOT/.local/miniconda3/ 12 | rm $BLAZINGSQL_ROOT/Miniconda3-py38_4.12.0-Linux-x86_64.sh 13 | fi 14 | 15 | export CONDA_ROOT=$BLAZINGSQL_ROOT/.local/miniconda3/bin/ 16 | 17 | # install blazingsql 18 | $CONDA_ROOT/conda create --yes -n bsql 19 | source $CONDA_ROOT/activate bsql 20 | $CONDA_ROOT/conda install --yes -c blazingsql -c rapidsai -c nvidia -c conda-forge -c defaults blazingsql python=3.8 cudatoolkit=11.4 -------------------------------------------------------------------------------- /blazingsql/run_query.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import glob 5 | import time 6 | import argparse 7 | import subprocess as subp 8 | 9 | from utility.profiler_logger import LOGGER 10 | 11 | 12 | def assemble_cmd(table, warm_sql, sql, sf, iter=1): 13 | py_interpreter = "./blazingsql/.local/miniconda3/envs/bsql/bin/python3" 14 | bin_cmd = f"{py_interpreter} blazingsql/execute_query.py --sql {sql} --table {table} --sf {sf} --iter {iter}" 15 | if warm_sql is not None: 16 | bin_cmd += f" --warm-sql {warm_sql}" 17 | LOGGER.debug(f"Assemble cmd {bin_cmd}") 18 | return bin_cmd 19 | 20 | 21 | def run(table, warm_sql, sql, sf): 22 | bin_cmd = assemble_cmd(table, warm_sql, sql, sf, 5) 23 | 24 | LOGGER.debug("Execute SQL") 25 | out, _ = subp.Popen( 26 | bin_cmd.split(" "), 27 | stdout=subp.PIPE, 28 | stdin=subp.PIPE, 29 | stderr=subp.STDOUT, 30 | env=os.environ.copy(), 31 | ).communicate() 32 | out = out.decode("utf-8") 33 | print(out) 34 | 35 | 36 | def run_ncu(table, warm_sql, sql, sf): 37 | skip_count = 0 38 | 39 | if warm_sql is not None: 40 | bin_cmd = assemble_cmd(table, None, warm_sql, sf) 41 | 42 | LOGGER.debug("Execute ncu warmup SQL") 43 | out, _ = subp.Popen( 44 | [ 45 | "./utility/ncu_profiler.py", 46 | f"--bin='{bin_cmd}'", 47 | "--cmd-flags='--target-processes all'", 48 | ], 49 | stdout=subp.PIPE, 50 | stdin=subp.PIPE, 51 | stderr=subp.STDOUT, 52 | env=os.environ.copy(), 53 | ).communicate() 54 | 55 | out = out.decode("utf-8") 56 | skip_count = int(out.split("\n")[0]) 57 | 58 | bin_cmd = assemble_cmd(table, warm_sql, sql, sf) 59 | 60 | LOGGER.debug("Execute ncu SQL") 61 | out, _ = subp.Popen( 62 | [ 63 | "./utility/ncu_profiler.py", 64 | f"--bin='{bin_cmd}'", 65 | "--cmd-flags='--target-processes all'", 66 | "-s", 67 | f"{skip_count}", 68 | ], 69 | stdout=subp.PIPE, 70 | stdin=subp.PIPE, 71 | stderr=subp.STDOUT, 72 | env=os.environ.copy(), 73 | ).communicate() 74 | out = out.decode("utf-8") 75 | print(out) 76 | 77 | 78 | def main(): 79 | parser = argparse.ArgumentParser() 80 | parser.add_argument( 81 | "--table", type=str, required=True, help="Table creation." 82 | ) 83 | parser.add_argument("--sql", type=str, required=True, help="SQL query.") 84 | parser.add_argument( 85 | "--warm-sql", type=str, default="", help="Warmup SQL query." 86 | ) 87 | parser.add_argument( 88 | "--sf", type=int, default=1, help="Scale factor for benchmarking." 89 | ) 90 | parser.add_argument( 91 | "--ncu", 92 | default=False, 93 | action="store_true", 94 | help="Enable NSight compute profiling.", 95 | ) 96 | args = parser.parse_args() 97 | 98 | with open("./.log/profiler.log", "w") as f: 99 | f.close() 100 | 101 | LOGGER.debug("Delete old report") 102 | for name in glob.glob("gpudb-perf.*"): 103 | os.remove(name) 104 | 105 | warm_sql = None if args.warm_sql == "" else args.warm_sql 106 | 107 | if args.ncu: 108 | run_ncu(args.table, warm_sql, args.sql, args.sf) 109 | else: 110 | run(args.table, warm_sql, args.sql, args.sf) 111 | 112 | 113 | if __name__ == "__main__": 114 | main() 115 | -------------------------------------------------------------------------------- /blazingsql/sql/aggregate.sql: -------------------------------------------------------------------------------- 1 | select sum(aggregate_1.attr) 2 | from aggregate_1 3 | group by aggregate_1.pk; -------------------------------------------------------------------------------- /blazingsql/sql/join.sql: -------------------------------------------------------------------------------- 1 | select * 2 | from join_1, 3 | join_2 4 | where join_1.pk = join_2.pk; -------------------------------------------------------------------------------- /blazingsql/sql/sample.sql: -------------------------------------------------------------------------------- 1 | select * 2 | from sample_1, 3 | sample_2 4 | where sample_1.pk = sample_2.pk; -------------------------------------------------------------------------------- /blazingsql/sql/scan.sql: -------------------------------------------------------------------------------- 1 | select * 2 | from scan_1; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_1col.sql: -------------------------------------------------------------------------------- 1 | select lo_orderdate 2 | from lineorder 3 | where lo_discount between 1 and 3; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_allcol.sql: -------------------------------------------------------------------------------- 1 | select lo_orderdate 2 | from lineorder 3 | where lo_discount between 1 and 3 4 | and lo_quantity < 10000; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q11.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice * lo_discount) as revenue 2 | from lineorder, 3 | ddate 4 | where lo_orderdate = d_datekey 5 | and d_year = 1993 6 | and lo_discount between 1 and 3 7 | and lo_quantity < 25; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q12.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice * lo_discount) as revenue 2 | from lineorder, 3 | ddate 4 | where lo_orderdate = d_datekey 5 | and d_yearmonthnum = 199401 6 | and lo_discount between 4 and 6 7 | and lo_quantity between 26 and 35; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q13.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice * lo_discount) as revenue 2 | from lineorder, 3 | ddate 4 | where lo_orderdate = d_datekey 5 | and d_weeknuminyear = 6 6 | and d_year = 1994 7 | and lo_discount between 5 and 7 8 | and lo_quantity between 26 and 35; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q21.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue), 2 | d_year, 3 | p_brand1 4 | from lineorder, 5 | ddate, 6 | part, 7 | supplier 8 | where lo_orderdate = d_datekey 9 | and lo_partkey = p_partkey 10 | and lo_suppkey = s_suppkey 11 | and p_category = 'MFGR#12' 12 | and s_region = 'AMERICA' 13 | group by d_year, 14 | p_brand1 15 | order by d_year, 16 | p_brand1; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q22.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue), 2 | d_year, 3 | p_brand1 4 | from lineorder, 5 | ddate, 6 | part, 7 | supplier 8 | where lo_orderdate = d_datekey 9 | and lo_partkey = p_partkey 10 | and lo_suppkey = s_suppkey 11 | and p_brand1 between 'MFGR#2221' and 'MFGR#2228' 12 | and s_region = 'ASIA' 13 | group by d_year, 14 | p_brand1 15 | order by d_year, 16 | p_brand1; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q23.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue), 2 | d_year, 3 | p_brand1 4 | from lineorder, 5 | ddate, 6 | part, 7 | supplier 8 | where lo_orderdate = d_datekey 9 | and lo_partkey = p_partkey 10 | and lo_suppkey = s_suppkey 11 | and p_brand1 = 'MFGR#2221' 12 | and s_region = 'EUROPE' 13 | group by d_year, 14 | p_brand1 15 | order by d_year, 16 | p_brand1; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q31.sql: -------------------------------------------------------------------------------- 1 | select c_nation, 2 | s_nation, 3 | d_year, 4 | sum(lo_revenue) as revenue 5 | from customer, 6 | lineorder, 7 | supplier, 8 | ddate 9 | where lo_custkey = c_custkey 10 | and lo_suppkey = s_suppkey 11 | and lo_orderdate = d_datekey 12 | and c_region = 'ASIA' 13 | and s_region = 'ASIA' 14 | and d_year >= 1992 15 | and d_year <= 1997 16 | group by c_nation, 17 | s_nation, 18 | d_year 19 | order by d_year asc, 20 | revenue desc; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q32.sql: -------------------------------------------------------------------------------- 1 | select c_city, 2 | s_city, 3 | d_year, 4 | sum(lo_revenue) as revenue 5 | from customer, 6 | lineorder, 7 | supplier, 8 | ddate 9 | where lo_custkey = c_custkey 10 | and lo_suppkey = s_suppkey 11 | and lo_orderdate = d_datekey 12 | and c_nation = 'UNITED STATES' 13 | and s_nation = 'UNITED STATES' 14 | and d_year >= 1992 15 | and d_year <= 1997 16 | group by c_city, 17 | s_city, 18 | d_year 19 | order by d_year asc, 20 | revenue desc; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q33.sql: -------------------------------------------------------------------------------- 1 | select c_city, 2 | s_city, 3 | d_year, 4 | sum(lo_revenue) as revenue 5 | from customer, 6 | lineorder, 7 | supplier, 8 | ddate 9 | where lo_custkey = c_custkey 10 | and lo_suppkey = s_suppkey 11 | and lo_orderdate = d_datekey 12 | and ( 13 | c_city = 'UNITED KI1' 14 | or c_city = 'UNITED KI5' 15 | ) 16 | and ( 17 | s_city = 'UNITED KI1' 18 | or s_city = 'UNITED KI5' 19 | ) 20 | and d_year >= 1992 21 | and d_year <= 1997 22 | group by c_city, 23 | s_city, 24 | d_year 25 | order by d_year asc, 26 | revenue desc; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q34.sql: -------------------------------------------------------------------------------- 1 | select c_city, 2 | s_city, 3 | d_year, 4 | sum(lo_revenue) as revenue 5 | from customer, 6 | lineorder, 7 | supplier, 8 | ddate 9 | where lo_custkey = c_custkey 10 | and lo_suppkey = s_suppkey 11 | and lo_orderdate = d_datekey 12 | and ( 13 | c_city = 'UNITED KI1' 14 | or c_city = 'UNITED KI5' 15 | ) 16 | and ( 17 | s_city = 'UNITED KI1' 18 | or s_city = 'UNITED KI5' 19 | ) 20 | and d_yearmonth = 'Dec1997' 21 | group by c_city, 22 | s_city, 23 | d_year 24 | order by d_year asc, 25 | revenue desc; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q41.sql: -------------------------------------------------------------------------------- 1 | select d_year, 2 | c_nation, 3 | sum(lo_revenue - lo_supplycost) as profit 4 | from ddate, 5 | customer, 6 | supplier, 7 | part, 8 | lineorder 9 | where lo_custkey = c_custkey 10 | and lo_suppkey = s_suppkey 11 | and lo_partkey = p_partkey 12 | and lo_orderdate = d_datekey 13 | and c_region = 'AMERICA' 14 | and s_region = 'AMERICA' 15 | and ( 16 | p_mfgr = 'MFGR#1' 17 | or p_mfgr = 'MFGR#2' 18 | ) 19 | group by d_year, 20 | c_nation 21 | order by d_year, 22 | c_nation; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q42.sql: -------------------------------------------------------------------------------- 1 | select d_year, 2 | s_nation, 3 | p_category, 4 | sum(lo_revenue - lo_supplycost) as profit 5 | from ddate, 6 | customer, 7 | supplier, 8 | part, 9 | lineorder 10 | where lo_custkey = c_custkey 11 | and lo_suppkey = s_suppkey 12 | and lo_partkey = p_partkey 13 | and lo_orderdate = d_datekey 14 | and c_region = 'AMERICA' 15 | and s_region = 'AMERICA' 16 | and ( 17 | d_year = 1997 18 | or d_year = 1998 19 | ) 20 | and ( 21 | p_mfgr = 'MFGR#1' 22 | or p_mfgr = 'MFGR#2' 23 | ) 24 | group by d_year, 25 | s_nation, 26 | p_category 27 | order by d_year, 28 | s_nation, 29 | p_category; -------------------------------------------------------------------------------- /blazingsql/sql/ssb_q43.sql: -------------------------------------------------------------------------------- 1 | select d_year, 2 | s_city, 3 | p_brand1, 4 | sum(lo_revenue - lo_supplycost) as profit 5 | from ddate, 6 | customer, 7 | supplier, 8 | part, 9 | lineorder 10 | where lo_custkey = c_custkey 11 | and lo_suppkey = s_suppkey 12 | and lo_partkey = p_partkey 13 | and lo_orderdate = d_datekey 14 | and c_region = 'AMERICA' 15 | and s_nation = 'UNITED STATES' 16 | and ( 17 | d_year = 1997 18 | or d_year = 1998 19 | ) 20 | and p_category = 'MFGR#14' 21 | group by d_year, 22 | s_city, 23 | p_brand1 24 | order by d_year, 25 | s_city, 26 | p_brand1; -------------------------------------------------------------------------------- /blazingsql/table/aggregate_1gb.txt: -------------------------------------------------------------------------------- 1 | aggregate_1,./data/storage/aggregate_268435456_10000.parquet -------------------------------------------------------------------------------- /blazingsql/table/join_100mb_1gb.txt: -------------------------------------------------------------------------------- 1 | join_1,./data/storage/join_dim_26214400.parquet 2 | join_2,./data/storage/join_fact_268435456.parquet -------------------------------------------------------------------------------- /blazingsql/table/join_1gb_1gb.txt: -------------------------------------------------------------------------------- 1 | join_1,./data/storage/join_dim_268435456.parquet 2 | join_2,./data/storage/join_fact_268435456.parquet -------------------------------------------------------------------------------- /blazingsql/table/join_test.txt: -------------------------------------------------------------------------------- 1 | join_1,./data/storage/join_dim_100.parquet 2 | join_2,./data/storage/join_fact_10000.parquet -------------------------------------------------------------------------------- /blazingsql/table/sample.txt: -------------------------------------------------------------------------------- 1 | sample_1,./data/storage/sample_1.parquet 2 | sample_2,./data/storage/sample_2.parquet -------------------------------------------------------------------------------- /blazingsql/table/scan_100mb.txt: -------------------------------------------------------------------------------- 1 | scan_1,./data/storage/join_dim_26214400.parquet -------------------------------------------------------------------------------- /blazingsql/table/scan_1gb.txt: -------------------------------------------------------------------------------- 1 | scan_1,./data/storage/join_fact_268435456.parquet -------------------------------------------------------------------------------- /blazingsql/table/ssb.txt: -------------------------------------------------------------------------------- 1 | customer,./data/storage/sf[sfph]_customer.parquet 2 | ddate,./data/storage/sf[sfph]_date.parquet 3 | lineorder,./data/storage/sf[sfph]_lineorder.parquet 4 | supplier,./data/storage/sf[sfph]_supplier.parquet 5 | part,./data/storage/sf[sfph]_part.parquet -------------------------------------------------------------------------------- /characterization_script/run_blazingsql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p tmp 4 | mkdir -p tmp/res 5 | 6 | env="CUDA_VISIBLE_DEVICES=$1" 7 | 8 | all_queries=(11 12 13 21 22 23 31 32 33 34) 9 | 10 | for sf_power in {0..4}; do 11 | 12 | sf=$((2 ** ${sf_power})) 13 | 14 | mkdir tmp/res/sf${sf} 15 | 16 | for qnum in ${all_queries[@]}; do 17 | cmd="${env} ./blazingsql/run_query.py --sql blazingsql/sql/ssb_q${qnum}.sql --table blazingsql/table/ssb.txt --sf ${sf} --ncu > output.txt" 18 | # echo $cmd > output.txt 19 | eval "$cmd" 20 | 21 | mkdir -p tmp/res/sf${sf}/q${qnum} 22 | mv gpudb-perf.ncu-rep tmp/res/sf${sf}/q${qnum}/ 23 | mv output.txt tmp/res/sf${sf}/q${qnum}/ 24 | done 25 | done -------------------------------------------------------------------------------- /characterization_script/run_crystal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p tmp 4 | mkdir -p tmp/res 5 | 6 | # compile_query() { 7 | # cd crystal/crystal_src 8 | # make clean 9 | # make 10 | # make bin/ssb/q11 && make bin/ssb/q12 && make bin/ssb/q13 && make bin/ssb/q21 && make bin/ssb/q22 && make bin/ssb/q23 && make bin/ssb/q31 && make bin/ssb/q32 && make bin/ssb/q33 && make bin/ssb/q34 && make bin/ssb/q41 && make bin/ssb/q42 && make bin/ssb/q43 11 | 12 | # cd ../../ 13 | # } 14 | 15 | all_queries=(11 12 13 21 22 23 31 32 33 34 41 42 43) 16 | 17 | env="CUDA_VISIBLE_DEVICES=$1" 18 | 19 | for sf_power in {0..0}; do 20 | 21 | sf=$((2 ** ${sf_power})) 22 | 23 | # sed "10d" crystal/crystal_src/src/ssb/ssb_utils.h >.tmp 24 | # sed "9 a\ 25 | # #define SF ${sf}" .tmp >crystal/crystal_src/src/ssb/ssb_utils.h 26 | 27 | # compile_query 28 | 29 | mkdir -p tmp/res/sf${sf} 30 | 31 | for qnum in ${all_queries[@]}; do 32 | 33 | mkdir -p tmp/res/sf${sf}/q${qnum} 34 | 35 | cmd1="${env} ./crystal/run_query.py --ncu --bin='./crystal/crystal_src/bin/ssb/q" 36 | cmd2="$qnum" 37 | cmd3="' --profile-run 1 --sf ${sf} > output.txt" 38 | cmd="$cmd1$cmd2$cmd3" 39 | eval "$cmd" 40 | 41 | mv gpudb-perf.ncu-rep tmp/res/sf${sf}/q${qnum}/ 42 | mv output.txt tmp/res/sf${sf}/q${qnum}/ 43 | done 44 | done 45 | -------------------------------------------------------------------------------- /characterization_script/run_heavydb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p tmp 4 | mkdir -p tmp/res 5 | 6 | env="CUDA_VISIBLE_DEVICES=$1" 7 | 8 | all_queries=(11 12 13 21 22 23 31 32 33 34 41 42 43) 9 | 10 | for sf_power in {0..4}; do 11 | 12 | sf=$((2 ** ${sf_power})) 13 | 14 | mkdir -p tmp/res/sf${sf} 15 | 16 | for qnum in ${all_queries[@]}; do 17 | 18 | cmd="./heavydb/run_query.py --sql ./heavydb/sql/ssb_q${qnum}_uncached.sql --sf ${sf} --ncu > output.txt" 19 | eval "$cmd" 20 | 21 | mkdir -p tmp/res/sf${sf}/q${qnum} 22 | mv gpudb-perf.ncu-rep tmp/res/sf${sf}/q${qnum}/ 23 | mv output.txt tmp/res/sf${sf}/q${qnum}/ 24 | done 25 | done -------------------------------------------------------------------------------- /concurrency_script/blazingsql_execute_query.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | os.environ["CONDA_PREFIX"] = os.path.join( 4 | os.path.dirname(os.path.abspath(__file__)), 5 | ".local/miniconda3/envs/bsql", 6 | ) 7 | 8 | import random 9 | import argparse 10 | import pandas as pd 11 | 12 | from blazingsql import BlazingContext 13 | from utility.profiler_logger import LOGGER 14 | 15 | 16 | def main(): 17 | parser = argparse.ArgumentParser() 18 | parser.add_argument("--num-iter", type=int, default=10) 19 | parser.add_argument("--sf", type=int, default=2) 20 | args = parser.parse_args() 21 | 22 | config = { 23 | "BLAZING_LOGGING_DIRECTORY": "./.log/blazingsql_log/", 24 | "BLAZING_LOCAL_LOGGING_DIRECTORY": "./.log/blazingsql_log/", 25 | } 26 | 27 | bc = BlazingContext(config_options=config) 28 | 29 | table_path = "./blazingsql/table/ssb.txt" 30 | sf = args.sf 31 | 32 | # table drop and creation 33 | LOGGER.debug("Drop and create tables") 34 | table_list = [] 35 | with open(table_path) as f: 36 | for line in f.read().splitlines(): 37 | table_list.append(tuple(line.split(","))) 38 | 39 | for i, (tb, src) in enumerate(table_list): 40 | if tb in bc.list_tables(): 41 | bc.drop_table(tb) 42 | LOGGER.debug(f"Create table: {tb} -- {src}") 43 | src = src.replace("[sfph]", str(sf)) 44 | src_df = pd.read_parquet(src) 45 | bc.create_table(tb, src_df) 46 | 47 | cur_table = ",".join(bc.list_tables()) 48 | LOGGER.debug(f"Table: {cur_table}") 49 | 50 | # execute sql 51 | LOGGER.debug("Parse SQL query") 52 | query_list = [] 53 | for query_num in [11, 12, 13, 21, 22, 23, 31, 32, 33, 34, 41, 42, 43]: 54 | query = "q{}".format(query_num) 55 | query_path = "./blazingsql/sql/ssb_{}.sql".format(query) 56 | with open(query_path) as f: 57 | sql = f.read().replace("\n", " ").rstrip() 58 | sql_list = sql.split(";")[:-1] 59 | assert len(sql_list) == 1 60 | query_list.append(sql_list[0]) 61 | 62 | random.shuffle(query_list) 63 | for _ in range(len(args.num_iter)): 64 | for query_str in query_list: 65 | _ = bc.sql(query_str) 66 | 67 | 68 | if __name__ == "__main__": 69 | main() 70 | -------------------------------------------------------------------------------- /concurrency_script/blazingsql_part_mig.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import time 5 | import argparse 6 | import subprocess as subp 7 | 8 | from threading import Thread 9 | from utility.profiler_logger import LOGGER 10 | 11 | 12 | def launch_cmd(cmd): 13 | out, _ = subp.Popen( 14 | cmd.split(" "), 15 | stdin=subp.PIPE, 16 | stdout=subp.PIPE, 17 | stderr=subp.STDOUT, 18 | ).communicate() 19 | return out.decode("utf-8") 20 | 21 | 22 | def get_device(): 23 | device_list = launch_cmd("nvidia-smi -L").strip("\n").split("\n") 24 | for i, device in enumerate(device_list): 25 | device = device.strip(")") 26 | device = device.split(":")[-1].strip(" ") 27 | device_list[i] = device 28 | return device_list 29 | 30 | 31 | def start_server(num_iter): 32 | py_interpreter = "./blazingsql/.local/miniconda3/envs/bsql/bin/python3" 33 | subp.Popen( 34 | [ 35 | py_interpreter, 36 | "./scheduler/blazingsql_execute_query.py", 37 | "--num-iter={}".format(num_iter), 38 | ], 39 | env=os.environ.copy(), 40 | ).wait() 41 | 42 | 43 | def main(): 44 | parser = argparse.ArgumentParser() 45 | parser.add_argument( 46 | "--iter", 47 | type=int, 48 | required=True, 49 | help="Number of iterations to run SSB benchmarks.", 50 | ) 51 | parser.add_argument( 52 | "--sf", 53 | type=int, 54 | default=2, 55 | help="Scale factor to run SSB benchmarks.", 56 | ) 57 | args = parser.parse_args() 58 | 59 | with open("./.log/profiler.log", "w") as f: 60 | f.close() 61 | 62 | mig_list = [d for d in get_device() if "MIG" in d] 63 | 64 | total_t = time.perf_counter() * 1000 65 | 66 | thread_pool = [] 67 | for i in range(len(mig_list)): 68 | os.environ["CUDA_VISIBLE_DEVICES"] = mig_list[i] 69 | thread_pool.append(Thread(target=start_server, args=(args.iter,))) 70 | for t in thread_pool: 71 | t.join() 72 | 73 | total_t = time.perf_counter() * 1000 - total_t 74 | print(f"Total: {total_t:.3f} ms") 75 | 76 | 77 | if __name__ == "__main__": 78 | main() 79 | -------------------------------------------------------------------------------- /concurrency_script/crystal_part_mig.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import time 5 | import argparse 6 | import subprocess as subp 7 | 8 | from threading import Thread 9 | from utility.profiler_logger import LOGGER 10 | 11 | 12 | def modify_scale_factor(sf): 13 | file_line_list = [] 14 | with open("./crystal/crystal_src/src/ssb/ssb_utils.h", "r") as f: 15 | for line in f.read().splitlines(): 16 | if "#define SF" in line: 17 | line = "#define SF {}".format(sf) 18 | file_line_list.append(line) 19 | 20 | with open("./crystal/crystal_src/src/ssb/ssb_utils.h", "w") as f: 21 | f.write("\n".join(file_line_list)) 22 | 23 | 24 | def recompile(): 25 | os.chdir("./crystal/crystal_src/") 26 | os.remove("./bin/ssb/all") 27 | out, _ = subp.Popen( 28 | [ 29 | "make", 30 | "bin/ssb/all", 31 | ], 32 | stdin=subp.PIPE, 33 | stdout=subp.PIPE, 34 | stderr=subp.STDOUT, 35 | ).communicate() 36 | os.chdir("../../") 37 | print(out.decode("utf-8")) 38 | 39 | 40 | def launch_cmd(cmd): 41 | out, _ = subp.Popen( 42 | cmd.split(" "), 43 | stdin=subp.PIPE, 44 | stdout=subp.PIPE, 45 | stderr=subp.STDOUT, 46 | ).communicate() 47 | return out.decode("utf-8") 48 | 49 | 50 | def get_device(): 51 | device_list = launch_cmd("nvidia-smi -L").strip("\n").split("\n") 52 | for i, device in enumerate(device_list): 53 | device = device.strip(")") 54 | device = device.split(":")[-1].strip(" ") 55 | device_list[i] = device 56 | return device_list 57 | 58 | 59 | def start_server(num_iter): 60 | subp.Popen( 61 | [ 62 | "./crystal/crystal_src/bin/ssb/all", 63 | "--t={}".format(num_iter), 64 | ], 65 | env=os.environ.copy(), 66 | ).wait() 67 | 68 | 69 | def main(): 70 | parser = argparse.ArgumentParser() 71 | parser.add_argument( 72 | "--iter", 73 | type=int, 74 | required=True, 75 | help="Number of iterations to run SSB benchmarks.", 76 | ) 77 | parser.add_argument( 78 | "--sf", 79 | type=int, 80 | default=2, 81 | help="Scale factor to run SSB benchmarks.", 82 | ) 83 | args = parser.parse_args() 84 | 85 | with open("./.log/profiler.log", "w") as f: 86 | f.close() 87 | 88 | modify_scale_factor(args.sf) 89 | recompile() 90 | 91 | mig_list = [d for d in get_device() if "MIG" in d] 92 | 93 | total_t = time.perf_counter() * 1000 94 | 95 | thread_pool = [] 96 | for i in range(len(mig_list)): 97 | os.environ["CUDA_VISIBLE_DEVICES"] = mig_list[i] 98 | thread_pool.append(Thread(target=start_server, args=(args.iter,))) 99 | for t in thread_pool: 100 | t.start() 101 | for t in thread_pool: 102 | t.join() 103 | 104 | total_t = time.perf_counter() * 1000 - total_t 105 | print(f"Total: {total_t:.3f} ms") 106 | 107 | 108 | if __name__ == "__main__": 109 | main() 110 | -------------------------------------------------------------------------------- /concurrency_script/crystal_part_mps.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import time 5 | import argparse 6 | import subprocess as subp 7 | 8 | from threading import Thread 9 | 10 | 11 | def modify_scale_factor(sf): 12 | file_line_list = [] 13 | with open("./crystal/crystal_src/src/ssb/ssb_utils.h", "r") as f: 14 | for line in f.read().splitlines(): 15 | if "#define SF" in line: 16 | line = "#define SF {}".format(sf) 17 | file_line_list.append(line) 18 | 19 | with open("./crystal/crystal_src/src/ssb/ssb_utils.h", "w") as f: 20 | f.write("\n".join(file_line_list)) 21 | 22 | 23 | def recompile(): 24 | os.chdir("./crystal/crystal_src/") 25 | if os.path.exists("./bin/ssb/all"): 26 | os.remove("./bin/ssb/all") 27 | out, _ = subp.Popen( 28 | [ 29 | "make", 30 | "bin/ssb/all", 31 | ], 32 | stdin=subp.PIPE, 33 | stdout=subp.PIPE, 34 | stderr=subp.STDOUT, 35 | ).communicate() 36 | os.chdir("../../") 37 | print(out.decode("utf-8")) 38 | 39 | 40 | def launch_cmd(cmd): 41 | out, _ = subp.Popen( 42 | cmd.split(" "), 43 | stdin=subp.PIPE, 44 | stdout=subp.PIPE, 45 | stderr=subp.STDOUT, 46 | ).communicate() 47 | return out.decode("utf-8") 48 | 49 | 50 | def start_server(num_iter): 51 | subp.Popen( 52 | [ 53 | "./crystal/crystal_src/bin/ssb/all", 54 | "--t={}".format(num_iter), 55 | ], 56 | env=os.environ.copy(), 57 | ).wait() 58 | 59 | 60 | def main(): 61 | parser = argparse.ArgumentParser() 62 | parser.add_argument( 63 | "--iter", 64 | type=int, 65 | required=True, 66 | help="Number of iterations to run SSB benchmarks.", 67 | ) 68 | parser.add_argument( 69 | "--sf", 70 | type=int, 71 | default=2, 72 | help="Scale factor to run SSB benchmarks.", 73 | ) 74 | parser.add_argument( 75 | "--num-worker", 76 | type=int, 77 | default=1, 78 | help="Number of workers." 79 | ) 80 | args = parser.parse_args() 81 | 82 | modify_scale_factor(args.sf) 83 | recompile() 84 | 85 | launch_cmd("nvidia-cuda-mps-control -d") 86 | 87 | total_t = time.perf_counter() * 1000 88 | 89 | thread_pool = [] 90 | for _ in range(args.num_worker): 91 | thread_pool.append(Thread(target=start_server, args=(args.iter,))) 92 | for t in thread_pool: 93 | t.start() 94 | for t in thread_pool: 95 | t.join() 96 | 97 | total_t = time.perf_counter() * 1000 - total_t 98 | print(f"Total: {total_t:.3f} ms") 99 | 100 | launch_cmd("echo quit | nvidia-cuda-mps-control") 101 | 102 | 103 | if __name__ == "__main__": 104 | main() -------------------------------------------------------------------------------- /crystal/crystal_src/.gitignore: -------------------------------------------------------------------------------- 1 | cub/ 2 | bin/ 3 | -------------------------------------------------------------------------------- /crystal/crystal_src/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Anil Shanbhag 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /crystal/crystal_src/Makefile: -------------------------------------------------------------------------------- 1 | CUDA_PATH ?= /usr/local/cuda 2 | CUDA_INC_PATH ?= $(CUDA_PATH)/include 3 | CUDA_BIN_PATH ?= $(CUDA_PATH)/bin 4 | 5 | NVCC = nvcc 6 | 7 | SM_TARGETS = -gencode=arch=compute_52,code=\"sm_52,compute_52\" 8 | SM_DEF = -DSM520 9 | 10 | #SM_TARGETS = -gencode=arch=compute_70,code=\"sm_70,compute_70\" 11 | #SM_DEF = -DSM700 12 | 13 | GENCODE_SM50 := -gencode arch=compute_52,code=sm_52 14 | #GENCODE_SM70 := -gencode arch=compute_70,code=sm_70 15 | GENCODE_FLAGS := $(GENCODE_SM50) 16 | 17 | NVCCFLAGS += --std=c++11 $(SM_DEF) -Xptxas="-dlcm=cg -v" -lineinfo -Xcudafe -\# 18 | 19 | SRC = src 20 | BIN = bin 21 | OBJ = obj 22 | 23 | CUB_DIR = cub/ 24 | 25 | INCLUDES = -I$(CUB_DIR) -I$(CUB_DIR)test -I. -I$(INC) 26 | 27 | $(OBJ)/%.o: $(SRC)/%.cu 28 | $(NVCC) -lcurand $(SM_TARGETS) $(NVCCFLAGS) $(CPU_ARCH) $(INCLUDES) $(LIBS) -O3 -dc $< -o $@ 29 | 30 | $(BIN)/%: $(OBJ)/%.o 31 | $(NVCC) $(SM_TARGETS) -lcurand $^ -o $@ 32 | 33 | setup: 34 | if [ ! -d "cub" ]; then \ 35 | wget https://github.com/NVlabs/cub/archive/1.6.4.zip; \ 36 | unzip 1.6.4.zip; \ 37 | mv cub-1.6.4 cub; \ 38 | rm 1.6.4.zip; \ 39 | fi 40 | mkdir -p bin/ssb obj/ssb 41 | mkdir -p bin/ops obj/ops 42 | 43 | clean: 44 | rm -rf bin/* obj/* 45 | -------------------------------------------------------------------------------- /crystal/crystal_src/README.md: -------------------------------------------------------------------------------- 1 | Crystal GPU Library 2 | ================= 3 | 4 | The Crystal library implements a collection of block-wide device functions that can be used to implement high performance implementations of SQL queries on GPUs. 5 | 6 | The package contains: 7 | 8 | * Crystal: `crystal/` contains the block-wide device functions 9 | * Implementations: `src/` contains SQL query operator implementations and implementations of 13 queries of the Star Schema Benchmark 10 | 11 | For full details of the Crystal, see our [paper](http://anilshanbhag.in/static/papers/crystal_sigmod20.pdf) 12 | 13 | ``` 14 | @inproceedings{shanbhag2020crystal, 15 | author = {Shanbhag, Anil and Madden, Samuel and Yu, Xiangyao}, 16 | title = {A Study of the Fundamental Performance Characteristics of GPUs and CPUs for Database Analytics}, 17 | year = {2020}, 18 | url = {https://doi.org/10.1145/3318464.3380595}, 19 | doi = {10.1145/3318464.3380595}, 20 | booktitle = {Proceedings of the 2020 ACM SIGMOD International Conference on Management of Data}, 21 | pages = {1617–1632}, 22 | numpages = {16}, 23 | location = {Portland, OR, USA}, 24 | series = {SIGMOD ’20} 25 | } 26 | ``` 27 | 28 | Usage 29 | ---- 30 | 31 | To use Crystal: 32 | 33 | * Copy out the `crystal` directory into your project. 34 | * Include Crystal 35 | ``` 36 | #include "crystal/crystal.cuh" 37 | ``` 38 | * Add the crystal directory to your include path 39 | 40 | To run the operator implementations: 41 | 42 | * Compile and run the operator. E.g., 43 | ``` 44 | make bin/ops/project 45 | ./bin/ops/project 46 | ``` 47 | 48 | To run the Star Schema Benchmark implementation: 49 | 50 | * Generate the test dataset 51 | 52 | ``` 53 | cd test/ 54 | 55 | # Generate the test generator / transformer binaries 56 | cd ssb/dbgen 57 | make 58 | cd ../loader 59 | make 60 | cd ../../ 61 | 62 | # Generate the test data and transform into columnar layout 63 | # Substitute with appropriate scale factor (eg: 1) 64 | python util.py ssb gen 65 | python util.py ssb transform 66 | ``` 67 | 68 | * Configure the benchmark settings 69 | ``` 70 | cd src/ssb/ 71 | # Edit SF and BASE_PATH in ssb_utils.h 72 | ``` 73 | 74 | * To run a query, say run q11 75 | ``` 76 | make bin/ssb/q11 77 | ./bin/ssb/q11 78 | ``` 79 | 80 | -------------------------------------------------------------------------------- /crystal/crystal_src/crystal/crystal.cuh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Block-wide functions 4 | #include "load.cuh" 5 | #include "pred.cuh" 6 | #include "store.cuh" 7 | #include "reduce.cuh" 8 | #include "join.cuh" 9 | #include "term.cuh" 10 | 11 | // Profiler helper functions 12 | #include "profiler.cuh" 13 | -------------------------------------------------------------------------------- /crystal/crystal_src/crystal/profiler.cuh: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define NSYS_ATTACH \ 4 | "\ 5 | #/bin/bash \n\ 6 | nsys start -o gpudb-perf --session gpudb-perf -f true\ 7 | " 8 | 9 | #define NSYS_DETACH \ 10 | "\ 11 | #/bin/bash \n\ 12 | nsys stop --session gpudb-perf\ 13 | " 14 | 15 | void nsys_attach(int trial, int num_trial) { 16 | // if (trial == num_trial) { 17 | // system(NSYS_ATTACH); 18 | // usleep(1000 * 1000); 19 | // } 20 | } 21 | 22 | void nsys_detach(int trial, int num_trial) { 23 | // if (trial == num_trial) { 24 | // usleep(1000 * 1000); 25 | // system(NSYS_DETACH); 26 | // } 27 | } -------------------------------------------------------------------------------- /crystal/crystal_src/crystal/reduce.cuh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | __device__ __forceinline__ T BlockSum( 5 | T item, 6 | T* shared 7 | ) { 8 | __syncthreads(); 9 | 10 | T val = item; 11 | const int warp_size = 32; 12 | int lane = threadIdx.x % warp_size; 13 | int wid = threadIdx.x / warp_size; 14 | 15 | // Calculate sum across warp 16 | for (int offset = 16; offset > 0; offset /= 2) { 17 | val += __shfl_down_sync(0xffffffff, val, offset); 18 | } 19 | 20 | // Store sum in buffer 21 | if (lane == 0) { 22 | shared[wid] = val; 23 | } 24 | 25 | __syncthreads(); 26 | 27 | // Load the sums into the first warp 28 | val = (threadIdx.x < blockDim.x / warp_size) ? shared[lane] : 0; 29 | 30 | // Calculate sum of sums 31 | if (wid == 0) { 32 | for (int offset = 16; offset > 0; offset /= 2) { 33 | val += __shfl_down_sync(0xffffffff, val, offset); 34 | } 35 | } 36 | 37 | return val; 38 | } 39 | 40 | template 41 | __device__ __forceinline__ T BlockSum( 42 | T (&items)[ITEMS_PER_THREAD], 43 | T* shared 44 | ) { 45 | T thread_sum = 0; 46 | 47 | #pragma unroll 48 | for (int ITEM = 0; ITEM < ITEMS_PER_THREAD; ITEM++) { 49 | thread_sum += items[ITEM]; 50 | } 51 | 52 | return BlockSum(thread_sum, shared); 53 | } 54 | -------------------------------------------------------------------------------- /crystal/crystal_src/crystal/store.cuh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | __device__ __forceinline__ void BlockStoreDirect( 5 | int tid, 6 | T* block_itr, 7 | T (&items)[ITEMS_PER_THREAD] 8 | ) { 9 | T* thread_itr = block_itr + tid; 10 | 11 | #pragma unroll 12 | for (int ITEM = 0; ITEM < ITEMS_PER_THREAD; ITEM++) { 13 | thread_itr[ITEM * BLOCK_THREADS] = items[ITEM]; 14 | } 15 | } 16 | 17 | template 18 | __device__ __forceinline__ void BlockStoreDirect( 19 | int tid, 20 | T* block_itr, 21 | T (&items)[ITEMS_PER_THREAD], 22 | int num_items 23 | ) { 24 | T* thread_itr = block_itr + tid; 25 | 26 | #pragma unroll 27 | for (int ITEM = 0; ITEM < ITEMS_PER_THREAD; ITEM++) { 28 | if (tid + (ITEM * BLOCK_THREADS) < num_items) { 29 | thread_itr[ITEM * BLOCK_THREADS] = items[ITEM]; 30 | } 31 | } 32 | } 33 | 34 | template 35 | __device__ __forceinline__ void BlockStore( 36 | T* out, 37 | T (&items)[ITEMS_PER_THREAD], 38 | int num_items 39 | ) { 40 | T* block_itr = out; 41 | 42 | if ((BLOCK_THREADS * ITEMS_PER_THREAD) == num_items) { 43 | BlockStoreDirect(threadIdx.x, block_itr, items); 44 | } else { 45 | BlockStoreDirect(threadIdx.x, block_itr, items, num_items); 46 | } 47 | } 48 | 49 | #if 0 50 | 51 | template 52 | __device__ __forceinline__ void BlockStoreDirect( 53 | int tid, 54 | T* block_itr, 55 | T (&items)[ITEMS_PER_THREAD] 56 | ) { 57 | T* thread_itr = block_itr + tid; 58 | 59 | #pragma unroll 60 | for (int ITEM = 0; ITEM < ITEMS_PER_THREAD; ITEM++) { 61 | items[ITEM] = thread_itr[ITEM * BLOCK_THREADS]; 62 | } 63 | } 64 | 65 | template 66 | __device__ __forceinline__ void BlockStoreDirect( 67 | int tid, 68 | T* block_itr, 69 | T (&items)[ITEMS_PER_THREAD] 70 | int num_items 71 | ) { 72 | T* thread_itr = block_itr + tid; 73 | 74 | #pragma unroll 75 | for (int ITEM = 0; ITEM < ITEMS_PER_THREAD; ITEM++) { 76 | if (tid + (ITEM * BLOCK_THREADS) < num_items) { 77 | items[ITEM] = thread_itr[ITEM * BLOCK_THREADS]; 78 | } 79 | } 80 | } 81 | 82 | template 83 | __device__ __forceinline__ void BlockStore( 84 | T* inp, 85 | T (&items)[ITEMS_PER_THREAD] 86 | int num_items 87 | ) { 88 | T* block_itr = inp + blockIdx.x * blockDim.x; 89 | 90 | if ((BLOCK_THREADS * ITEMS_PER_THREAD) == num_items) { 91 | BlockStoreDirect(threadIdx.x, block_itr, items); 92 | } else { 93 | BlockStoreDirect(threadIdx.x, block_itr, items, num_items); 94 | } 95 | } 96 | 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /crystal/crystal_src/crystal/term.cuh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | __device__ __forceinline__ void 5 | Term(int (&selection_flags)[ITEMS_PER_THREAD]) { 6 | int count = 0; 7 | for (int ITEM = 0; ITEM < ITEMS_PER_THREAD; ITEM++) { 8 | count += selection_flags[ITEM]; 9 | } 10 | if (count == 0) { 11 | printf("Term\n"); 12 | return; 13 | } 14 | } -------------------------------------------------------------------------------- /crystal/crystal_src/gpudb-perf.nsys-rep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiashenC/gpudb-char-and-opt/0395d20abdc50ae07f3d90e9dc4ddc18c2759e29/crystal/crystal_src/gpudb-perf.nsys-rep -------------------------------------------------------------------------------- /crystal/crystal_src/src/ops/utils/gpu_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define SETUP_TIMING() cudaEvent_t start, stop; cudaEventCreate(&start); cudaEventCreate(&stop); 4 | 5 | #define TIME_FUNC(f,t) { \ 6 | cudaEventRecord(start, 0); \ 7 | f; \ 8 | cudaEventRecord(stop, 0); \ 9 | cudaEventSynchronize(stop); \ 10 | cudaEventElapsedTime(&t, start,stop); \ 11 | } 12 | 13 | #define CLEANUP(vec) if(vec)CubDebugExit(g_allocator.DeviceFree(vec)) 14 | 15 | #define ALLOCATE(vec,size) CubDebugExit(g_allocator.DeviceAllocate((void**)&vec, size)) 16 | 17 | template 18 | T* loadToGPU(T* src, int numEntries, cub::CachingDeviceAllocator& g_allocator) { 19 | T* dest; 20 | CubDebugExit(g_allocator.DeviceAllocate((void**)&dest, sizeof(T) * numEntries)); 21 | CubDebugExit(cudaMemcpy(dest, src, sizeof(T) * numEntries, cudaMemcpyHostToDevice)); 22 | return dest; 23 | } 24 | 25 | #define TILE_SIZE (BLOCK_THREADS * ITEMS_PER_THREAD) 26 | 27 | #define CHECK_ERROR() { \ 28 | cudaDeviceSynchronize(); \ 29 | cudaError_t error = cudaGetLastError(); \ 30 | if(error != cudaSuccess) \ 31 | { \ 32 | printf("CUDA error: %s\n", cudaGetErrorString(error)); \ 33 | exit(-1); \ 34 | } \ 35 | } 36 | -------------------------------------------------------------------------------- /crystal/crystal_src/src/ssb/gpu_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define SETUP_TIMING() cudaEvent_t start, stop; cudaEventCreate(&start); cudaEventCreate(&stop); 4 | 5 | #define TIME_FUNC(f,t) { \ 6 | cudaEventRecord(start, 0); \ 7 | f; \ 8 | cudaEventRecord(stop, 0); \ 9 | cudaEventSynchronize(stop); \ 10 | cudaEventElapsedTime(&t, start,stop); \ 11 | } 12 | 13 | #define CLEANUP(vec) if(vec)CubDebugExit(g_allocator.DeviceFree(vec)) 14 | 15 | #define ALLOCATE(vec,size) CubDebugExit(g_allocator.DeviceAllocate((void**)&vec, size)) 16 | 17 | template 18 | T* loadToGPU(T* src, int numEntries, cub::CachingDeviceAllocator& g_allocator) { 19 | T* dest; 20 | CubDebugExit(g_allocator.DeviceAllocate((void**)&dest, sizeof(T) * numEntries)); 21 | CubDebugExit(cudaMemcpy(dest, src, sizeof(T) * numEntries, cudaMemcpyHostToDevice)); 22 | return dest; 23 | } 24 | 25 | #define TILE_SIZE (BLOCK_THREADS * ITEMS_PER_THREAD) 26 | 27 | #define CHECK_ERROR() { \ 28 | cudaDeviceSynchronize(); \ 29 | cudaError_t error = cudaGetLastError(); \ 30 | if(error != cudaSuccess) \ 31 | { \ 32 | printf("CUDA error: %s\n", cudaGetErrorString(error)); \ 33 | exit(-1); \ 34 | } \ 35 | } 36 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/.gitignore: -------------------------------------------------------------------------------- 1 | data/ 2 | dbgen/*.o 3 | dbgen/dbgen 4 | loader/loader 5 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/dbgen/CHANGES: -------------------------------------------------------------------------------- 1 | # @(#)CHANGES 2.1.8.18 2 | 08 Dec 1998 Release 2.0.0 3 | 15 Mar 1998 Release 2.0.0 pre-release 4 | 06 Feb 1998 Release 1.3.1 5 | 15 Dec 1996 Release 1.2.0 6 | 08 Aug 1996 Release 1.1.0D 7 | 01 May 1996 Release 1.1.0C 8 | 29 Jan 1996 Release 1.1.0B 9 | 23 Jan 1996 Release 1.1.0A 10 | 19 Dec 1995 Release 1.1.0 11 | 11 Sep 1995 Release 1.0.1 12 | 13 Mar 1995 Release 1.0 13 | 14 | 15 | Changes between 990830 and 991011 16 | File Bug ID 17 | ---- ------ 18 | s.2.sql 00059 Removing extra comma 19 | s.dss.h 00061 20 | s.config.h 00061 21 | s.driver.c 00060 adding missed change from Larry 22 | s.makefile 00058 23 | s.rnd.c 00061 24 | s.HISTORY 00061 25 | s.history.html 00061 26 | s.mr.sh 00058 miscelaneous corrections 27 | s.bug.template 00058 removing extraneous spaces 28 | s.bug.template changed titles 29 | 30 | 31 | Changes between 199910 and 000511 32 | File Bug ID 33 | ---- ------ 34 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/dbgen/README: -------------------------------------------------------------------------------- 1 | Note: In our research paper we use the SSB instead of SSBM 2 | Version of 2/28/10: 3 | Cardinality of supplier fixed to follow benchmark spec: now 2000*SF 4 | (previously was 10000*SF, in error): line 226, driver.c 5 | Type of time value changed from long to time_t (now 64 bits on Windows): 6 | line 688, build.c 7 | Building in Visual Studio 2008: 8 | Use Win32 console project, not using precompiled headers, 9 | in Properties>C/C++>CommandLine, additional options: 10 | /D "SSBM" /D "DBNAME" /D "DB2" (for DB2) 11 | Building using makefile_win: set for DB2 build: 12 | nmake -f makefile_win 13 | (Change DATABASE symbol for other database) 14 | 15 | SSBM dbgen readme: 16 | 17 | SSBM is based on TPC-H dbgen source. The coding style and architecture 18 | follows the TPCH dbgen. The original TPCH dbgen code stays untouched and 19 | all new code related to SSBM dbgen follow the "#ifdef SSBM" statements. 20 | 21 | For original detailed TPC-H documentation, please refer TPCH_README 22 | document under the same directory. Here we just list few things that 23 | are specific to SSBM. 24 | 25 | 26 | 1. How is SSBM DBGEN built? 27 | 28 | Same idea as TPCH dbgen setup, which requires user to create an 29 | appropriate makefile, using makefile.suite as a basis. Make sure to 30 | use "SSBM" for the workload variable. 31 | 32 | Type "make" to compile and to generate the SSBM dbgen executable. 33 | Please refer to Porting.Notes for more details and for 34 | suggested compile time options. 35 | 36 | Note: If you want to generate the data files to a diffent directory, you should 37 | copy the dbgen executable as well as the dists.dss file to that directory. 38 | 39 | 2. How to generate SSBM data files? 40 | To generate the dimension tables: 41 | 42 | (customer.tbl) 43 | dbgen -s 1 -T c 44 | 45 | (part.tbl) 46 | dbgen -s 1 -T p 47 | 48 | (supplier.tbl) 49 | dbgen -s 1 -T s 50 | 51 | (date.tbl) 52 | dbgen -s 1 -T d 53 | 54 | (fact table lineorder.tbl) 55 | dbgen -s 1 -T l 56 | 57 | (for all SSBM tables) 58 | dbgen -s 1 -T a 59 | 60 | To generate the refresh (insert/delete) data set: 61 | (create delete.[1-4] and lineorder.tbl.u[1-4] with refreshing fact 0.05%) 62 | dbgen -s 1 -r 5 -U 4 63 | 64 | where "-r 5" specifies refreshin fact n/10000 65 | "-U 4" specifies 4 segments for deletes and inserts 66 | 67 | At this moment there is no QGEN for SSBM. So 68 | the command line options related to those features won't apply. 69 | 70 | 3. What are the changes upon TPC-H dbgen 71 | 72 | changes made upon original TPC-H dbgen 73 | 74 | 1. removed snowflake tables such as nation and region (done) 75 | 2. removed the partsupply table (done) 76 | 3. removed the order table (done) 77 | 4. renamed the fact table as Lineorder and added/removed many fields 78 | ( done) 79 | 5. added the date dimension table (done) 80 | 6. adding and removing fields in dimension tables (done) 81 | 7. have data cross reference for supplycost, revenue in lineorder (done) 82 | 8. apply the refreshing only to lineorder table (done) 83 | 84 | The command line option keeps the same as TPC-H dbgen (The -T options 85 | are changed to reflect different set of tables) 86 | 87 | ===================== End of README ======================================== 88 | 89 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/dbgen/bcd2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sccsid: @(#)bcd2.h 2.1.8.1 3 | */ 4 | int bin_bcd2(long binary, long *low_res, long *high_res); 5 | int bcd2_bin(long *dest, long bcd); 6 | int bcd2_add(long *bcd_low, long *bcd_high, long addend); 7 | int bcd2_sub(long *bcd_low, long *bcd_high, long subend); 8 | int bcd2_mul(long *bcd_low, long *bcd_high, long multiplier); 9 | int bcd2_div(long *bcd_low, long *bcd_high, long divisor); 10 | long bcd2_mod(long *bcd_low, long *bcd_high, long modulo); 11 | long bcd2_cmp(long *bcd_low, long *bcd_high, long compare); 12 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/dbgen/build.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiashenC/gpudb-char-and-opt/0395d20abdc50ae07f3d90e9dc4ddc18c2759e29/crystal/crystal_src/test/ssb/dbgen/build.c -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/dbgen/convert.py: -------------------------------------------------------------------------------- 1 | nations = """ALGERIA 2 | ARGENTINA 3 | BRAZIL 4 | CANADA 5 | EGYPT 6 | ETHIOPIA 7 | FRANCE 8 | GERMANY 9 | INDIA 10 | INDONESIA 11 | IRAN 12 | IRAQ 13 | JAPAN 14 | JORDAN 15 | KENYA 16 | MOROCCO 17 | MOZAMBIQUE 18 | PERU 19 | CHINA 20 | ROMANIA 21 | SAUDI ARABIA 22 | VIETNAM 23 | RUSSIA 24 | UNITED KINGDOM 25 | UNITED STATES 26 | """ 27 | nations = nations.split('\n') 28 | 29 | regions = """AFRICA 30 | AMERICA 31 | ASIA 32 | EUROPE 33 | MIDDLE EAST 34 | """ 35 | regions = regions.split('\n') 36 | 37 | # process suppliers 38 | lines = open('supplier.tbl').readlines() 39 | o = [] 40 | for line in lines: 41 | try: 42 | parts = line.split('|') 43 | parts[4] = str(nations.index(parts[4])) 44 | parts[5] = str(regions.index(parts[5])) 45 | parts[3] = str(int(parts[4]) * 10 + int(parts[3][-1])) 46 | o.append('|'.join(parts)) 47 | except: 48 | print line 49 | break 50 | 51 | f = open('supplier.tbl.p','w') 52 | for line in o: 53 | f.write(line) 54 | f.close() 55 | 56 | # process customers 57 | lines = open('customer.tbl').readlines() 58 | o = [] 59 | for line in lines: 60 | try: 61 | parts = line.split('|') 62 | parts[4] = str(nations.index(parts[4])) 63 | parts[5] = str(regions.index(parts[5])) 64 | parts[3] = str(int(parts[4]) * 10 + int(parts[3][-1])) 65 | o.append('|'.join(parts)) 66 | except: 67 | print line 68 | break 69 | 70 | f = open('customer.tbl.p','w') 71 | for line in o: 72 | f.write(line) 73 | f.close() 74 | 75 | # process parts 76 | lines = open('part.tbl').readlines() 77 | o = [] 78 | for line in lines: 79 | try: 80 | parts = line.split('|') 81 | parts[2] = parts[2].split('#')[-1] 82 | parts[3] = parts[3].split('#')[-1] 83 | parts[4] = parts[4].split('#')[-1] 84 | o.append('|'.join(parts)) 85 | except: 86 | print line 87 | break 88 | 89 | f = open('part.tbl.p','w') 90 | for line in o: 91 | f.write(line) 92 | f.close() 93 | 94 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/dbgen/dss.ddl: -------------------------------------------------------------------------------- 1 | -- Sccsid: @(#)dss.ddl 2.1.8.1 2 | CREATE TABLE TPCD.NATION ( N_NATIONKEY INTEGER NOT NULL, 3 | N_NAME CHAR(25) NOT NULL, 4 | N_REGIONKEY INTEGER NOT NULL, 5 | N_COMMENT VARCHAR(152)); 6 | 7 | CREATE TABLE TPCD.REGION ( R_REGIONKEY INTEGER NOT NULL, 8 | R_NAME CHAR(25) NOT NULL, 9 | R_COMMENT VARCHAR(152)); 10 | 11 | CREATE TABLE TPCD.PART ( P_PARTKEY INTEGER NOT NULL, 12 | P_NAME VARCHAR(55) NOT NULL, 13 | P_MFGR CHAR(25) NOT NULL, 14 | P_BRAND CHAR(10) NOT NULL, 15 | P_TYPE VARCHAR(25) NOT NULL, 16 | P_SIZE INTEGER NOT NULL, 17 | P_CONTAINER CHAR(10) NOT NULL, 18 | P_RETAILPRICE DECIMAL(15,2) NOT NULL, 19 | P_COMMENT VARCHAR(23) NOT NULL ); 20 | 21 | CREATE TABLE TPCD.SUPPLIER ( S_SUPPKEY INTEGER NOT NULL, 22 | S_NAME CHAR(25) NOT NULL, 23 | S_ADDRESS VARCHAR(40) NOT NULL, 24 | S_NATIONKEY INTEGER NOT NULL, 25 | S_PHONE CHAR(15) NOT NULL, 26 | S_ACCTBAL DECIMAL(15,2) NOT NULL, 27 | S_COMMENT VARCHAR(101) NOT NULL); 28 | 29 | CREATE TABLE TPCD.PARTSUPP ( PS_PARTKEY INTEGER NOT NULL, 30 | PS_SUPPKEY INTEGER NOT NULL, 31 | PS_AVAILQTY INTEGER NOT NULL, 32 | PS_SUPPLYCOST DECIMAL(15,2) NOT NULL, 33 | PS_COMMENT VARCHAR(199) NOT NULL ); 34 | 35 | CREATE TABLE TPCD.CUSTOMER ( C_CUSTKEY INTEGER NOT NULL, 36 | C_NAME VARCHAR(25) NOT NULL, 37 | C_ADDRESS VARCHAR(40) NOT NULL, 38 | C_NATIONKEY INTEGER NOT NULL, 39 | C_PHONE CHAR(15) NOT NULL, 40 | C_ACCTBAL DECIMAL(15,2) NOT NULL, 41 | C_MKTSEGMENT CHAR(10) NOT NULL, 42 | C_COMMENT VARCHAR(117) NOT NULL); 43 | 44 | CREATE TABLE TPCD.ORDERS ( O_ORDERKEY INTEGER NOT NULL, 45 | O_CUSTKEY INTEGER NOT NULL, 46 | O_ORDERSTATUS CHAR(1) NOT NULL, 47 | O_TOTALPRICE DECIMAL(15,2) NOT NULL, 48 | O_ORDERDATE DATE NOT NULL, 49 | O_ORDERPRIORITY CHAR(15) NOT NULL, -- R 50 | O_CLERK CHAR(15) NOT NULL, -- R 51 | O_SHIPPRIORITY INTEGER NOT NULL, 52 | O_COMMENT VARCHAR(79) NOT NULL); 53 | 54 | CREATE TABLE TPCD.LINEITEM ( L_ORDERKEY INTEGER NOT NULL, 55 | L_PARTKEY INTEGER NOT NULL, 56 | L_SUPPKEY INTEGER NOT NULL, 57 | L_LINENUMBER INTEGER NOT NULL, 58 | L_QUANTITY DECIMAL(15,2) NOT NULL, 59 | L_EXTENDEDPRICE DECIMAL(15,2) NOT NULL, 60 | L_DISCOUNT DECIMAL(15,2) NOT NULL, 61 | L_TAX DECIMAL(15,2) NOT NULL, 62 | L_RETURNFLAG CHAR(1) NOT NULL, 63 | L_LINESTATUS CHAR(1) NOT NULL, 64 | L_SHIPDATE DATE NOT NULL, 65 | L_COMMITDATE DATE NOT NULL, 66 | L_RECEIPTDATE DATE NOT NULL, 67 | L_SHIPINSTRUCT CHAR(25) NOT NULL, -- R 68 | L_SHIPMODE CHAR(10) NOT NULL, -- R 69 | L_COMMENT VARCHAR(44) NOT NULL); 70 | 71 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/dbgen/dss.ri: -------------------------------------------------------------------------------- 1 | -- Sccsid: @(#)dss.ri 2.1.8.1 2 | -- TPCD Benchmark Version 8.0 3 | 4 | CONNECT TO TPCD; 5 | 6 | --ALTER TABLE TPCD.REGION DROP PRIMARY KEY; 7 | --ALTER TABLE TPCD.NATION DROP PRIMARY KEY; 8 | --ALTER TABLE TPCD.PART DROP PRIMARY KEY; 9 | --ALTER TABLE TPCD.SUPPLIER DROP PRIMARY KEY; 10 | --ALTER TABLE TPCD.PARTSUPP DROP PRIMARY KEY; 11 | --ALTER TABLE TPCD.ORDERS DROP PRIMARY KEY; 12 | --ALTER TABLE TPCD.LINEITEM DROP PRIMARY KEY; 13 | --ALTER TABLE TPCD.CUSTOMER DROP PRIMARY KEY; 14 | 15 | 16 | -- For table REGION 17 | ALTER TABLE TPCD.REGION 18 | ADD PRIMARY KEY (R_REGIONKEY); 19 | 20 | -- For table NATION 21 | ALTER TABLE TPCD.NATION 22 | ADD PRIMARY KEY (N_NATIONKEY); 23 | 24 | ALTER TABLE TPCD.NATION 25 | ADD FOREIGN KEY NATION_FK1 (N_REGIONKEY) references TPCD.REGION; 26 | 27 | COMMIT WORK; 28 | 29 | -- For table PART 30 | ALTER TABLE TPCD.PART 31 | ADD PRIMARY KEY (P_PARTKEY); 32 | 33 | COMMIT WORK; 34 | 35 | -- For table SUPPLIER 36 | ALTER TABLE TPCD.SUPPLIER 37 | ADD PRIMARY KEY (S_SUPPKEY); 38 | 39 | ALTER TABLE TPCD.SUPPLIER 40 | ADD FOREIGN KEY SUPPLIER_FK1 (S_NATIONKEY) references TPCD.NATION; 41 | 42 | COMMIT WORK; 43 | 44 | -- For table PARTSUPP 45 | ALTER TABLE TPCD.PARTSUPP 46 | ADD PRIMARY KEY (PS_PARTKEY,PS_SUPPKEY); 47 | 48 | COMMIT WORK; 49 | 50 | -- For table CUSTOMER 51 | ALTER TABLE TPCD.CUSTOMER 52 | ADD PRIMARY KEY (C_CUSTKEY); 53 | 54 | ALTER TABLE TPCD.CUSTOMER 55 | ADD FOREIGN KEY CUSTOMER_FK1 (C_NATIONKEY) references TPCD.NATION; 56 | 57 | COMMIT WORK; 58 | 59 | -- For table LINEITEM 60 | ALTER TABLE TPCD.LINEITEM 61 | ADD PRIMARY KEY (L_ORDERKEY,L_LINENUMBER); 62 | 63 | COMMIT WORK; 64 | 65 | -- For table ORDERS 66 | ALTER TABLE TPCD.ORDERS 67 | ADD PRIMARY KEY (O_ORDERKEY); 68 | 69 | COMMIT WORK; 70 | 71 | -- For table PARTSUPP 72 | ALTER TABLE TPCD.PARTSUPP 73 | ADD FOREIGN KEY PARTSUPP_FK1 (PS_SUPPKEY) references TPCD.SUPPLIER; 74 | 75 | COMMIT WORK; 76 | 77 | ALTER TABLE TPCD.PARTSUPP 78 | ADD FOREIGN KEY PARTSUPP_FK2 (PS_PARTKEY) references TPCD.PART; 79 | 80 | COMMIT WORK; 81 | 82 | -- For table ORDERS 83 | ALTER TABLE TPCD.ORDERS 84 | ADD FOREIGN KEY ORDERS_FK1 (O_CUSTKEY) references TPCD.CUSTOMER; 85 | 86 | COMMIT WORK; 87 | 88 | -- For table LINEITEM 89 | ALTER TABLE TPCD.LINEITEM 90 | ADD FOREIGN KEY LINEITEM_FK1 (L_ORDERKEY) references TPCD.ORDERS; 91 | 92 | COMMIT WORK; 93 | 94 | ALTER TABLE TPCD.LINEITEM 95 | ADD FOREIGN KEY LINEITEM_FK2 (L_PARTKEY,L_SUPPKEY) references 96 | TPCD.PARTSUPP; 97 | 98 | COMMIT WORK; 99 | 100 | 101 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/dbgen/makefile_win: -------------------------------------------------------------------------------- 1 | VC="c:/Program Files/Microsoft Visual Studio 9.0/VC" 2 | WIN_INC="C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include" 3 | WIN_LIB="C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib" 4 | #VC = "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7" 5 | VCLIB = $(VC)\LIB 6 | # @(#)makefile.suite 2.1.8.1 7 | ################ 8 | ## CHANGE NAME OF ANSI COMPILER HERE 9 | ################ 10 | CC =cl.exe 11 | # Current values for DATABASE are: INFORMIX, DB2, TDAT (Teradata) 12 | # SQLSERVER, SYBASE 13 | # Current values for MACHINE are: ATT, DOS, WIN32 HP, IBM, ICL, MVS, 14 | # SGI, SUN, U2200, VMS, LINUX 15 | # Current values for WORKLOAD are: SSBM, TPCH, TPCR 16 | DATABASE=DB2 17 | MACHINE =WIN32 18 | WORKLOAD =SSBM 19 | # 20 | # add -EDTERABYTE if orderkey will execeed 32 bits (SF >= 300) 21 | # and make the appropriate change in gen_schema() of runit.sh 22 | CFLAGS = -DDBNAME=\"dss\" -D$(MACHINE) -D$(DATABASE) -D$(WORKLOAD) /I$(VC)\include /I$(WIN_INC) 23 | 24 | #LDFLAGS = -O 25 | # The OBJ,EXE and LIB macros will need to be changed for compilation under 26 | # Windows NT 27 | OBJ = .obj 28 | EXE = .exe 29 | LIBS =$(VCLIB)\libcmt.lib $(VCLIB)\oldnames.lib $(VCLIB)\oldnames.lib $(WIN_LIB)\kernel32.lib 30 | # 31 | # NO CHANGES SHOULD BE NECESSARY BELOW THIS LINE 32 | ############### 33 | # 34 | PROG1 = dbgen$(EXE) 35 | PROG2 = qgen$(EXE) 36 | PROGS = $(PROG1) $(PROG2) 37 | # 38 | HDR1 = dss.h rnd.h config.h dsstypes.h shared.h bcd2.h 39 | HDR2 = tpcd.h permute.h 40 | HDR = $(HDR1) $(HDR2) 41 | # 42 | SRC1 = build.c driver.c bm_utils.c rnd.c print.c load_stub.c bcd2.c \ 43 | speed_seed.c text.c permute.c 44 | SRC2 = qgen.c varsub.c 45 | SRC = $(SRC1) $(SRC2) 46 | # 47 | OBJ1 = build$(OBJ) driver$(OBJ) bm_utils$(OBJ) rnd$(OBJ) print$(OBJ) \ 48 | load_stub$(OBJ) bcd2$(OBJ) speed_seed$(OBJ) text$(OBJ) permute$(OBJ) 49 | OBJ2 = build$(OBJ) bm_utils$(OBJ) qgen$(OBJ) rnd$(OBJ) varsub$(OBJ) \ 50 | text$(OBJ) bcd2$(OBJ) permute$(OBJ) speed_seed$(OBJ) 51 | OBJS = $(OBJ1) $(OBJ2) 52 | # 53 | SETS = dists.dss 54 | DOC=README HISTORY PORTING.NOTES BUGS 55 | DDL = dss.ddl dss.ri 56 | OTHER=makefile.suite $(SETS) $(DDL) 57 | # case is *important* in TEST_RES 58 | TEST_RES = O.res L.res c.res s.res P.res S.res n.res r.res 59 | # 60 | DBGENSRC=$(SRC1) $(HDR1) $(OTHER) $(DOC) $(SRC2) $(HDR2) $(SRC3) 61 | QD=1.sql 2.sql 3.sql 4.sql 5.sql 6.sql 7.sql 8.sql 9.sql 10.sql \ 62 | 11.sql 12.sql 13.sql 14.sql 15.sql 16.sql 17.sql 18.sql \ 63 | 19.sql 20.sql 21.sql 22.sql 64 | VARIANTS= 8a.sql 12a.sql 13a.sql 14a.sql 15a.sql 65 | ANS = 1.ans 2.ans 3.ans 4.ans 5.ans 6.ans 7.ans 8.ans 9.ans 10.ans 11.ans \ 66 | 12.ans 13.ans 14.ans 15.ans 16.ans 17.ans 18.ans 19.ans 20.ans \ 67 | 21.ans 22.ans 68 | QSRC = $(FQD) $(VARIANTS) 69 | ALLSRC=$(DBGENSRC) 70 | TREE_DOC=tree.readme tree.changes appendix.readme appendix.version answers.readme queries.readme variants.readme 71 | JUNK = 72 | # 73 | all: $(PROGS) 74 | 75 | $(PROG1): $(OBJ1) $(SETS) 76 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ1) $(LIBS) 77 | 78 | $(PROG2): permute.h $(OBJ2) 79 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ2) $(LIBS) 80 | 81 | clean: 82 | del /F $(PROGS) $(OBJS) $(JUNK) 83 | 84 | $(OBJ1): $(HDR1) 85 | $(OBJ2): dss.h tpcd.h config.h 86 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/dbgen/permute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)permute.h 2.1.8.1 3 | */ 4 | long permutation[41][22] = 5 | { 6 | {14, 2, 9,20, 6,17,18, 8,21,13, 3,22,16, 4,11,15, 1,10,19, 5, 7,12}, 7 | {21, 3,18, 5,11, 7, 6,20,17,12,16,15,13,10, 2, 8,14,19, 9,22, 1, 4}, 8 | { 6,17,14,16,19,10, 9, 2,15, 8, 5,22,12, 7,13,18, 1, 4,20, 3,11,21}, 9 | { 8, 5, 4, 6,17, 7, 1,18,22,14, 9,10,15,11,20, 2,21,19,13,16,12, 3}, 10 | { 5,21,14,19,15,17,12, 6, 4, 9, 8,16,11, 2,10,18, 1,13, 7,22, 3,20}, 11 | {21,15, 4, 6, 7,16,19,18,14,22,11,13, 3, 1, 2, 5, 8,20,12,17,10, 9}, 12 | {10, 3,15,13, 6, 8, 9, 7, 4,11,22,18,12, 1, 5,16, 2,14,19,20,17,21}, 13 | {18, 8,20,21, 2, 4,22,17, 1,11, 9,19, 3,13, 5, 7,10,16, 6,14,15,12}, 14 | {19, 1,15,17, 5, 8, 9,12,14, 7, 4, 3,20,16, 6,22,10,13, 2,21,18,11}, 15 | { 8,13, 2,20,17, 3, 6,21,18,11,19,10,15, 4,22, 1, 7,12, 9,14, 5,16}, 16 | { 6,15,18,17,12, 1, 7, 2,22,13,21,10,14, 9, 3,16,20,19,11, 4, 8, 5}, 17 | {15,14,18,17,10,20,16,11, 1, 8, 4,22, 5,12, 3, 9,21, 2,13, 6,19, 7}, 18 | { 1, 7,16,17,18,22,12, 6, 8, 9,11, 4, 2, 5,20,21,13,10,19, 3,14,15}, 19 | {21,17, 7, 3, 1,10,12,22, 9,16, 6,11, 2, 4, 5,14, 8,20,13,18,15,19}, 20 | { 2, 9, 5, 4,18, 1,20,15,16,17, 7,21,13,14,19, 8,22,11,10, 3,12, 6}, 21 | {16, 9,17, 8,14,11,10,12, 6,21, 7, 3,15, 5,22,20, 1,13,19, 2, 4,18}, 22 | { 1, 3, 6, 5, 2,16,14,22,17,20, 4, 9,10,11,15, 8,12,19,18,13, 7,21}, 23 | { 3,16, 5,11,21, 9, 2,15,10,18,17, 7, 8,19,14,13, 1, 4,22,20, 6,12}, 24 | {14, 4,13, 5,21,11, 8, 6, 3,17, 2,20, 1,19,10, 9,12,18,15, 7,22,16}, 25 | { 4,12,22,14, 5,15,16, 2, 8,10,17, 9,21, 7, 3, 6,13,18,11,20,19, 1}, 26 | {16,15,14,13, 4,22,18,19, 7, 1,12,17, 5,10,20, 3, 9,21,11, 2, 6, 8}, 27 | {20,14,21,12,15,17, 4,19,13,10,11, 1,16, 5,18, 7, 8,22, 9, 6, 3, 2}, 28 | {16,14,13, 2,21,10,11, 4, 1,22,18,12,19, 5, 7, 8, 6, 3,15,20, 9,17}, 29 | {18,15, 9,14,12, 2, 8,11,22,21,16, 1, 6,17, 5,10,19, 4,20,13, 3, 7}, 30 | { 7, 3,10,14,13,21,18, 6,20, 4, 9, 8,22,15, 2, 1, 5,12,19,17,11,16}, 31 | {18, 1,13, 7,16,10,14, 2,19, 5,21,11,22,15, 8,17,20, 3, 4,12, 6, 9}, 32 | {13, 2,22, 5,11,21,20,14, 7,10, 4, 9,19,18, 6, 3, 1, 8,15,12,17,16}, 33 | {14,17,21, 8, 2, 9, 6, 4, 5,13,22, 7,15, 3, 1,18,16,11,10,12,20,19}, 34 | {10,22, 1,12,13,18,21,20, 2,14,16, 7,15, 3, 4,17, 5,19, 6, 8, 9,11}, 35 | {10, 8, 9,18,12, 6, 1, 5,20,11,17,22,16, 3,13, 2,15,21,14,19, 7, 4}, 36 | { 7,17,22, 5, 3,10,13,18, 9, 1,14,15,21,19,16,12, 8, 6,11,20, 4, 2}, 37 | { 2, 9,21, 3, 4, 7, 1,11,16, 5,20,19,18, 8,17,13,10,12,15, 6,14,22}, 38 | {15,12, 8, 4,22,13,16,17,18, 3, 7, 5, 6, 1, 9,11,21,10,14,20,19, 2}, 39 | {15,16, 2,11,17, 7, 5,14,20, 4,21, 3,10, 9,12, 8,13, 6,18,19,22, 1}, 40 | { 1,13,11, 3, 4,21, 6,14,15,22,18, 9, 7, 5,10,20,12,16,17, 8,19, 2}, 41 | {14,17,22,20, 8,16, 5,10, 1,13, 2,21,12, 9, 4,18, 3, 7, 6,19,15,11}, 42 | { 9,17, 7, 4, 5,13,21,18,11, 3,22, 1, 6,16,20,14,15,10, 8, 2,12,19}, 43 | {13,14, 5,22,19,11, 9, 6,18,15, 8,10, 7, 4,17,16, 3, 1,12, 2,21,20}, 44 | {20, 5, 4,14,11, 1, 6,16, 8,22, 7, 3, 2,12,21,19,17,13,10,15,18, 9}, 45 | { 3, 7,14,15, 6, 5,21,20,18,10, 4,16,19, 1,13, 9, 8,17,11,12,22, 2}, 46 | {13,15,17, 1,22,11, 3, 4, 7,20,14,21, 9, 8, 2,18,16, 6,10,12, 5,19} 47 | }; 48 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/dbgen/shared.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sccsid: @(#)shared.h 2.1.8.1 3 | * Modified for SSBM 4 | */ 5 | #define N_CMNT_LEN 72 6 | #define N_CMNT_MAX 152 7 | #define R_CMNT_LEN 72 8 | #define R_CMNT_MAX 152 9 | #define MONEY_SCL 0.01 10 | #define V_STR_HGH 1.6 11 | 12 | #ifdef SSBM 13 | #define P_NAME_LEN 22 14 | #define P_MFG_LEN 6 15 | #define P_COLOR_LEN 3 16 | #define P_COLOR_MAX 11 17 | #define P_TYPE_MAX 25 18 | #define P_CAT_LEN 7 19 | #define P_CAT_MIN 1 20 | #define P_CAT_MAX 5 21 | #define P_CAT_SD 97 22 | #define S_NATION_NAME_LEN 15 23 | #define S_REGION_NAME_LEN 12 24 | #define C_NATION_NAME_LEN 15 25 | #define C_REGION_NAME_LEN 12 26 | #define C_NAT_SD 16 27 | #define C_REG_SD 3 28 | #define O_SHIP_STRU_LEN 25 29 | #define O_SHIP_MODE_LEN 10 30 | #define O_SHIP_PRIO_LEN 1 31 | #define D_DATE_LEN 18 32 | #define D_DAYWEEK_LEN 9 33 | #define D_YEARMONTH_LEN 7 34 | #define D_SEASON_LEN 12 35 | #define D_MONTH_LEN 9 36 | #define D_STARTDATE 694245661 /*corresponding to 1/1/1992 1:1:1*/ 37 | #define NAMTION_BRIEF_LEN 9 38 | #define CITY_CODE_SEED 15 39 | #define NUM_DAYS 2556 40 | #define NUM_SEASONS 5 41 | #define NUM_HOLIDAYS 10 42 | #define CITY_FIX 10 43 | #else 44 | 45 | #define P_NAME_LEN 55 46 | #define P_MFG_LEN 25 47 | 48 | #endif 49 | 50 | #define P_BRND_LEN 10 51 | 52 | #ifdef SSBM 53 | #define P_TYPE_LEN 12 54 | 55 | #else 56 | 57 | #define P_TYPE_LEN 25 58 | 59 | #endif 60 | 61 | #define P_CNTR_LEN 10 62 | #define P_CMNT_LEN 14 63 | #define P_CMNT_MAX 23 64 | #define P_CAT_SEED 25 65 | 66 | #define S_NAME_LEN 25 67 | 68 | #ifdef SSBM 69 | #define S_ADDR_LEN 15 70 | #define S_ADDR_MAX 25 71 | #else 72 | 73 | #define S_ADDR_LEN 25 74 | #define S_ADDR_MAX 40 75 | #endif 76 | 77 | #define S_CMNT_LEN 63 78 | #define S_CMNT_MAX 101 79 | #define PS_CMNT_LEN 124 80 | #define PS_CMNT_MAX 199 81 | 82 | #ifdef SSBM 83 | #define C_NAME_LEN 25 84 | #define C_MSEG_MIN 1 85 | #define C_MSEG_MAX 5 86 | #define C_ADDR_LEN 15 87 | #define C_ADDR_MAX 25 88 | #else 89 | #define C_NAME_LEN 18 90 | #define C_ADDR_LEN 25 91 | #define C_ADDR_MAX 40 92 | #endif 93 | 94 | #define C_MSEG_LEN 10 95 | #define C_CMNT_LEN 73 96 | #define C_CMNT_MAX 117 97 | 98 | #ifdef SSBM 99 | #define O_OPRIO_LEN 8 100 | 101 | #else 102 | #define O_OPRIO_LEN 15 103 | 104 | #endif 105 | 106 | #define O_CLRK_LEN 15 107 | #define O_CMNT_LEN 49 108 | #define O_CMNT_MAX 79 109 | #define L_CMNT_LEN 27 110 | #define L_CMNT_MAX 44 111 | #define L_INST_LEN 25 112 | #define L_SMODE_LEN 10 113 | #define T_ALPHA_LEN 10 114 | #define DATE_LEN 13 /* long enough to hold either date format */ 115 | #define NATION_LEN 25 116 | #define REGION_LEN 25 117 | #define PHONE_LEN 15 118 | 119 | #ifdef SSBM 120 | #define MAXAGG_LEN 10 /* max component length for a agg str */ 121 | 122 | #else 123 | #define MAXAGG_LEN 20 /* max component length for a agg str */ 124 | 125 | #endif 126 | 127 | #define P_CMNT_SD 6 128 | #define PS_CMNT_SD 9 129 | #define O_CMNT_SD 12 130 | #define C_ADDR_SD 26 131 | #define C_CMNT_SD 31 132 | #define S_ADDR_SD 32 133 | #define S_CMNT_SD 36 134 | #define L_CMNT_SD 25 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/dbgen/tpcd.h: -------------------------------------------------------------------------------- 1 | /***************************************************************** 2 | * Title: tpcd.h for TPC D 3 | * Sccsid: @(#)tpcd.h 2.1.8.1 4 | * Description: 5 | * X 6 | * 7 | ***************************************************************** 8 | */ 9 | #define DFLT 0x0001 10 | #define OUTPUT 0x0002 11 | #define EXPLAIN 0x0004 12 | #define DBASE 0x0008 13 | #define VERBOSE 0x0010 14 | #define TIMING 0x0020 15 | #define LOG 0x0040 16 | #define QUERY 0x0080 17 | #define REFRESH 0x0100 18 | #define ANSI 0x0200 19 | #define SEED 0x0400 20 | #define COMMENT 0x0800 21 | #define INIT 0x1000 22 | #define TERMINATE 0x2000 23 | #define DFLT_NUM 0x4000 24 | 25 | /* 26 | * general defines 27 | */ 28 | #define VTAG ':' /* flags a variable substitution */ 29 | #define ofp stdout /* make the routine a filter */ 30 | #define QDIR_TAG "DSS_QUERY" /* variable to point to queries */ 31 | #define QDIR_DFLT "." /* and its default */ 32 | 33 | /* 34 | * database portability defines 35 | */ 36 | #ifdef DB2 37 | #define GEN_QUERY_PLAN "SET CURRENT EXPLAIN SNAPSHOT ON;" 38 | #define START_TRAN "" 39 | #define END_TRAN "COMMIT WORK;" 40 | #define SET_OUTPUT "" 41 | #define SET_ROWCOUNT "--#SET ROWS_FETCH %d\n" 42 | #define SET_DBASE "CONNECT TO %s ;\n" 43 | #endif 44 | 45 | #ifdef INFORMIX 46 | #define GEN_QUERY_PLAN "SET EXPLAIN ON;" 47 | #define START_TRAN "BEGIN WORK;" 48 | #define END_TRAN "COMMIT WORK;" 49 | #define SET_OUTPUT "OUTPUT TO " 50 | #define SET_ROWCOUNT "FIRST %d" 51 | #define SET_DBASE "database %s ;\n" 52 | #endif 53 | 54 | #ifdef SQLSERVER 55 | #define GEN_QUERY_PLAN "set showplan on\nset noexec on\ngo\n" 56 | #define START_TRAN "begin transaction\ngo\n" 57 | #define END_TRAN "commit transaction\ngo\n" 58 | #define SET_OUTPUT "" 59 | #define SET_ROWCOUNT "set rowcount %d\ngo\n\n" 60 | #define SET_DBASE "use %s\ngo\n" 61 | #endif 62 | 63 | #ifdef SYBASE 64 | #define GEN_QUERY_PLAN "set showplan on\nset noexec on\ngo\n" 65 | #define START_TRAN "begin transaction\ngo\n" 66 | #define END_TRAN "commit transaction\ngo\n" 67 | #define SET_OUTPUT "" 68 | #define SET_ROWCOUNT "set rowcount %d\ngo\n\n" 69 | #define SET_DBASE "use %s\ngo\n" 70 | #endif 71 | 72 | #ifdef TDAT 73 | #define GEN_QUERY_PLAN "EXPLAIN" 74 | #define START_TRAN "BEGIN TRANSACTION" 75 | #define END_TRAN "END TRANSACTION" 76 | #define SET_OUTPUT ".SET FORMAT OFF\n.EXPORT REPORT file=" 77 | #define SET_ROWCOUNT ".SET RETCANCEL ON\n.SET RETLIMIT %d\n" 78 | #define SET_DBASE ".LOGON %s\n" 79 | #endif 80 | 81 | #define MAX_VARS 8 /* max number of host vars in any query */ 82 | #define QLEN_MAX 2048 /* max length of any query */ 83 | #define QUERIES_PER_SET 22 84 | #define MAX_PIDS 50 85 | 86 | EXTERN int flags; 87 | EXTERN int s_cnt; 88 | EXTERN char *osuff; 89 | EXTERN int stream; 90 | EXTERN char *lfile; 91 | EXTERN char *ifile; 92 | EXTERN char *tfile; 93 | 94 | #define MAX_PERMUTE 41 95 | #ifdef DECLARER 96 | int rowcnt_dflt[QUERIES_PER_SET + 1] = 97 | {-1,-1,100,10,-1,-1,-1,-1,-1,-1,20,-1,-1,-1,-1,-1,-1,-1,100,-1,-1,100,-1}; 98 | int rowcnt; 99 | #define SEQUENCE(stream, query) permutation[stream % MAX_PERMUTE][query - 1] 100 | #else 101 | extern int rowcnt_dflt[]; 102 | extern int rowcnt; 103 | #endif 104 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/load.sql: -------------------------------------------------------------------------------- 1 | copy customer from '/big_fast_drive/anil/dbops/test/ssb/data/s1/customer.tbl' delimiter '|'; 2 | copy ddate from '/big_fast_drive/anil/dbops/test/ssb/data/s1/date.tbl' delimiter '|'; 3 | copy lineorder from '/big_fast_drive/anil/dbops/test/ssb/data/s1/lineorder.tbl' delimiter '|'; 4 | copy part from '/big_fast_drive/anil/dbops/test/ssb/data/s1/part.tbl' delimiter '|'; 5 | copy supplier from '/big_fast_drive/anil/dbops/test/ssb/data/s1/supplier.tbl' delimiter '|'; 6 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q11.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice*lo_discount) as revenue 2 | from lineorder, ddate 3 | where lo_orderdate = d_datekey 4 | and d_year = 1993 5 | and lo_discount between 1 and 3 6 | and lo_quantity < 25 7 | 8 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q12.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice*lo_discount) as revenue 2 | from lineorder, ddate 3 | where lo_orderdate = d_datekey 4 | and d_yearmonthnum = 199401 5 | and lo_discount between 4 and 6 6 | and lo_quantity between 26 and 35 7 | 8 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q13.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice*lo_discount) as revenue 2 | from lineorder, ddate 3 | where lo_orderdate = d_datekey 4 | and d_weeknuminyear = 6 5 | and d_year = 1994 6 | and lo_discount between 5 and 7 7 | and lo_quantity between 26 and 35 8 | 9 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q21.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue), d_year, p_brand1 2 | from lineorder, ddate, part, supplier 3 | where lo_orderdate = d_datekey 4 | and lo_partkey = p_partkey 5 | and lo_suppkey = s_suppkey 6 | and p_category = 'MFGR#12' 7 | and s_region = 'AMERICA' 8 | group by d_year, p_brand1 9 | order by d_year, p_brand1 10 | 11 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q22.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue), d_year, p_brand1 2 | from lineorder, ddate, part, supplier 3 | where lo_orderdate = d_datekey 4 | and lo_partkey = p_partkey 5 | and lo_suppkey = s_suppkey 6 | and p_brand1 between 7 | 'MFGR#2221' and 'MFGR#2228' 8 | and s_region = 'ASIA' 9 | group by d_year, p_brand1 10 | order by d_year, p_brand1 11 | 12 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q23.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue), d_year, p_brand1 2 | from lineorder, ddate, part, supplier 3 | where lo_orderdate = d_datekey 4 | and lo_partkey = p_partkey 5 | and lo_suppkey = s_suppkey 6 | and p_brand1 = 'MFGR#2221' 7 | and s_region = 'EUROPE' 8 | group by d_year, p_brand1 9 | order by d_year, p_brand1 10 | 11 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q31.sql: -------------------------------------------------------------------------------- 1 | select c_nation, s_nation, d_year, sum(lo_revenue) 2 | as revenue from customer, lineorder, supplier, ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_orderdate = d_datekey 6 | and c_region = 'ASIA' and s_region = 'ASIA' 7 | and d_year >= 1992 and d_year <= 1997 8 | group by c_nation, s_nation, d_year 9 | order by d_year asc, revenue desc 10 | 11 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q32.sql: -------------------------------------------------------------------------------- 1 | select c_city, s_city, d_year, sum(lo_revenue) as revenue 2 | from customer, lineorder, supplier, ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_orderdate = d_datekey 6 | and c_nation = 'UNITED STATES' 7 | and s_nation = 'UNITED STATES' 8 | and d_year >= 1992 and d_year <= 1997 9 | group by c_city, s_city, d_year 10 | order by d_year asc, revenue desc 11 | 12 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q33.sql: -------------------------------------------------------------------------------- 1 | select c_city, s_city, d_year, sum(lo_revenue) as revenue 2 | from customer, lineorder, supplier, ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_orderdate = d_datekey 6 | and (c_city='UNITED KI1' 7 | or c_city='UNITED KI5') 8 | and (s_city='UNITED KI1' 9 | or s_city='UNITED KI5') 10 | and d_year >= 1992 and d_year <= 1997 11 | group by c_city, s_city, d_year 12 | order by d_year asc, revenue desc 13 | 14 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q34.sql: -------------------------------------------------------------------------------- 1 | select c_city, s_city, d_year, sum(lo_revenue) as revenue 2 | from customer, lineorder, supplier, ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_orderdate = d_datekey 6 | and (c_city='UNITED KI1' or 7 | c_city='UNITED KI5') 8 | and (s_city='UNITED KI1' or 9 | s_city='UNITED KI5') 10 | and d_yearmonth = 'Dec1997' 11 | group by c_city, s_city, d_year 12 | order by d_year asc, revenue desc 13 | 14 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q41.sql: -------------------------------------------------------------------------------- 1 | select d_year, c_nation, sum(lo_revenue - lo_supplycost) as profit 2 | from ddate, customer, supplier, part, lineorder 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_partkey = p_partkey 6 | and lo_orderdate = d_datekey 7 | and c_region = 'AMERICA' 8 | and s_region = 'AMERICA' 9 | and (p_mfgr = 'MFGR#1' or p_mfgr = 'MFGR#2') 10 | group by d_year, c_nation 11 | order by d_year, c_nation 12 | 13 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q42.sql: -------------------------------------------------------------------------------- 1 | select d_year, s_nation, p_category, sum(lo_revenue - lo_supplycost) as profit 2 | from ddate, customer, supplier, part, lineorder 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_partkey = p_partkey 6 | and lo_orderdate = d_datekey 7 | and c_region = 'AMERICA' 8 | and s_region = 'AMERICA' 9 | and (d_year = 1997 or d_year = 1998) 10 | and (p_mfgr = 'MFGR#1' 11 | or p_mfgr = 'MFGR#2') 12 | group by d_year, s_nation, p_category 13 | order by d_year, s_nation, p_category 14 | 15 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/q43.sql: -------------------------------------------------------------------------------- 1 | select d_year, s_city, p_brand1, sum(lo_revenue - lo_supplycost) as profit 2 | from ddate, customer, supplier, part, lineorder 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_partkey = p_partkey 6 | and lo_orderdate = d_datekey 7 | and c_region = 'AMERICA' 8 | and s_nation = 'UNITED STATES' 9 | and (d_year = 1997 or d_year = 1998) 10 | and p_category = 'MFGR#14' 11 | group by d_year, s_city, p_brand1 12 | order by d_year, s_city, p_brand1 13 | 14 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/original/schema.sql: -------------------------------------------------------------------------------- 1 | create table lineorder ( 2 | lo_orderkey integer not null, 3 | lo_linenumber integer not null, 4 | lo_custkey integer not null, 5 | lo_partkey integer not null, 6 | lo_suppkey integer not null, 7 | lo_orderdate integer not null, 8 | lo_orderpriority char(15) not null, 9 | lo_shippriority char(1) not null, 10 | lo_quantity integer not null, 11 | lo_extendedprice float not null, 12 | lo_ordtotalprice float not null, 13 | lo_discount float not null, 14 | lo_revenue float not null, 15 | lo_supplycost float not null, 16 | lo_tax integer not null, 17 | lo_commitdate integer not null, 18 | lo_shopmode char(10) not null, 19 | primary key (lo_orderkey,lo_linenumber) 20 | ); 21 | 22 | create table part ( 23 | p_partkey integer not null, 24 | p_name varchar(22) not null, 25 | p_mfgr char(6) not null, 26 | p_category char(7) not null, 27 | p_brand1 char(9) not null, 28 | p_color varchar(11) not null, 29 | p_type varchar(25) not null, 30 | p_size integer not null, 31 | p_container char(10) not null, 32 | primary key (p_partkey) 33 | ); 34 | 35 | create table supplier ( 36 | s_suppkey integer not null, 37 | s_name char(25) not null, 38 | s_address varchar(25) not null, 39 | s_city char(10) not null, 40 | s_nation char(15) not null, 41 | s_region char(12) not null, 42 | s_phone char(15) not null, 43 | primary key (s_suppkey) 44 | ); 45 | 46 | create table customer ( 47 | c_custkey integer not null, 48 | c_name varchar(25) not null, 49 | c_address varchar(25) not null, 50 | c_city char(10) not null, 51 | c_nation char(15) not null, 52 | c_region char(12) not null, 53 | c_phone char(15) not null, 54 | c_mktsegment char(10) not null, 55 | primary key (c_custkey) 56 | ); 57 | 58 | create table ddate ( 59 | d_datekey integer not null, 60 | d_date char(18) not null, 61 | d_dayofweek char(9) not null, 62 | d_month char(9) not null, 63 | d_year integer not null, 64 | d_yearmonthnum integer not null, 65 | d_yearmonth char(7) not null, 66 | d_daynuminweek integer not null, 67 | d_daynuminmonth integer not null, 68 | d_daynuminyear integer not null, 69 | d_monthnuminyear integer not null, 70 | d_weeknuminyear integer not null, 71 | d_sellingseasin varchar(12) not null, 72 | d_lastdayinweekfl integer not null, 73 | d_lastdayinmonthfl integer not null, 74 | d_holidayfl integer not null, 75 | d_weekdayfl integer not null, 76 | primary key (d_datekey) 77 | ); 78 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/load.sql: -------------------------------------------------------------------------------- 1 | copy customer from '/big_fast_drive/anil/dbops/test/ssb/data/s1/customer.tbl.p' delimiter '|'; 2 | copy ddate from '/big_fast_drive/anil/dbops/test/ssb/data/s1/date.tbl' delimiter '|'; 3 | copy lineorder from '/big_fast_drive/anil/dbops/test/ssb/data/s1/lineorder.tbl' delimiter '|'; 4 | copy part from '/big_fast_drive/anil/dbops/test/ssb/data/s1/part.tbl.p' delimiter '|'; 5 | copy supplier from '/big_fast_drive/anil/dbops/test/ssb/data/s1/supplier.tbl.p' delimiter '|'; 6 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/p1.sql: -------------------------------------------------------------------------------- 1 | select d_year,c_nation, COUNT(*) as profit 2 | from lineorder,supplier,customer,part,ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_partkey = p_partkey 6 | and lo_orderdate = d_datekey 7 | and c_region = 1 8 | and s_region = 1 9 | and (p_mfgr = 0 or p_mfgr = 1) 10 | group by d_year,c_nation; 11 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q11.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice * lo_discount) as revenue 2 | from lineorder 3 | where lo_orderdate >= 19930101 and lo_orderdate <= 19940101 and lo_discount>=1 4 | and lo_discount<=3 5 | and lo_quantity<25; 6 | 7 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q12.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice * lo_discount) as revenue 2 | from lineorder 3 | where lo_orderdate >= 19940101 and lo_orderdate <= 19940131 4 | and lo_discount>=4 and lo_discount<=6 5 | and lo_quantity>=26 6 | and lo_quantity<=35; 7 | 8 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q13.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice * lo_discount) as revenue 2 | from lineorder 3 | where lo_orderdate >= 19940204 4 | and lo_orderdate <= 19940210 5 | and lo_discount>=5 6 | and lo_discount<=7 7 | and lo_quantity>=26 8 | and lo_quantity<=35; 9 | 10 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q21.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue),d_year,p_brand1 2 | from lineorder,part,supplier,ddate 3 | where lo_orderdate = d_datekey 4 | and lo_partkey = p_partkey 5 | and lo_suppkey = s_suppkey 6 | and p_category = 1 7 | and s_region = 1 8 | group by d_year,p_brand1; 9 | 10 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q22.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue),d_year,p_brand1 2 | from lineorder, part, supplier,ddate 3 | where lo_orderdate = d_datekey 4 | and lo_partkey = p_partkey 5 | and lo_suppkey = s_suppkey 6 | and p_brand1 >= 260 7 | and p_brand1 <= 267 8 | and s_region = 2 9 | group by d_year,p_brand1; 10 | 11 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q23.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue),d_year,p_brand1 2 | from lineorder,part,supplier,ddate 3 | where lo_orderdate = d_datekey 4 | and lo_partkey = p_partkey 5 | and lo_suppkey = s_suppkey 6 | and p_brand1 = 260 7 | and s_region = 3 8 | group by d_year,p_brand1; 9 | 10 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q31.sql: -------------------------------------------------------------------------------- 1 | select c_nation,s_nation,d_year,sum(lo_revenue) as revenue 2 | from lineorder,customer, supplier,ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_orderdate = d_datekey 6 | and c_region = 2 7 | and s_region = 2 8 | and d_year >= 1992 and d_year <= 1997 9 | group by c_nation,s_nation,d_year; 10 | 11 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q32.sql: -------------------------------------------------------------------------------- 1 | select c_city,s_city,d_year,sum(lo_revenue) as revenue 2 | from lineorder,customer,supplier,ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_orderdate = d_datekey 6 | and c_nation = 24 7 | and s_nation = 24 8 | and d_year >=1992 and d_year <= 1997 9 | group by c_city,s_city,d_year; 10 | 11 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q33.sql: -------------------------------------------------------------------------------- 1 | select c_city,s_city,d_year,sum(lo_revenue) as revenue 2 | from lineorder,customer,supplier,ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_orderdate = d_datekey 6 | and (c_city = 231 or c_city = 235) 7 | and (s_city = 231 or s_city = 235) 8 | and d_year >=1992 and d_year <= 1997 9 | group by c_city,s_city,d_year; 10 | 11 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q34.sql: -------------------------------------------------------------------------------- 1 | select c_city,s_city,d_year,sum(lo_revenue) as revenue 2 | from lineorder,customer,supplier,ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_orderdate = d_datekey 6 | and (c_city = 231 or c_city = 235) 7 | and (s_city = 231 or s_city = 235) 8 | and d_yearmonthnum = 199712 9 | group by c_city,s_city,d_year; 10 | 11 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q41.sql: -------------------------------------------------------------------------------- 1 | select d_year,c_nation,sum(lo_revenue-lo_supplycost) as profit 2 | from lineorder,supplier,customer,part,ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_partkey = p_partkey 6 | and lo_orderdate = d_datekey 7 | and c_region = 1 8 | and s_region = 1 9 | and (p_mfgr = 0 or p_mfgr = 1) 10 | group by d_year,c_nation; 11 | 12 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q42.sql: -------------------------------------------------------------------------------- 1 | select d_year,s_nation,p_category,sum(lo_revenue-lo_supplycost) as profit 2 | from lineorder,customer,supplier,part,ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_partkey = p_partkey 6 | and lo_orderdate = d_datekey 7 | and c_region = 1 8 | and s_region = 1 9 | and (d_year = 1997 or d_year = 1998) 10 | and (p_mfgr = 0 or p_mfgr = 1) 11 | group by d_year,s_nation, p_category; 12 | 13 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/q43.sql: -------------------------------------------------------------------------------- 1 | select d_year,s_city,p_brand1,sum(lo_revenue-lo_supplycost) as profit 2 | from lineorder,supplier,customer,part,ddate 3 | where lo_custkey = c_custkey 4 | and lo_suppkey = s_suppkey 5 | and lo_partkey = p_partkey 6 | and lo_orderdate = d_datekey 7 | and c_region = 1 8 | and s_nation = 24 9 | and (d_year = 1997 or d_year = 1998) 10 | and p_category = 3 11 | group by d_year,s_city,p_brand1; 12 | 13 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/schema.sql: -------------------------------------------------------------------------------- 1 | create table lineorder ( 2 | lo_orderkey integer not null, 3 | lo_linenumber integer not null, 4 | lo_custkey integer not null, 5 | lo_partkey integer not null, 6 | lo_suppkey integer not null, 7 | lo_orderdate integer not null, 8 | lo_orderpriority char(15) not null, 9 | lo_shippriority char(1) not null, 10 | lo_quantity integer not null, 11 | lo_extendedprice float not null, 12 | lo_ordtotalprice float not null, 13 | lo_discount float not null, 14 | lo_revenue float not null, 15 | lo_supplycost float not null, 16 | lo_tax integer not null, 17 | lo_commitdate integer not null, 18 | lo_shopmode char(10) not null, 19 | primary key (lo_orderkey,lo_linenumber) 20 | ); 21 | 22 | create table part ( 23 | p_partkey integer not null, 24 | p_name varchar(22) not null, 25 | p_mfgr integer not null, 26 | p_category integer not null, 27 | p_brand1 integer not null, 28 | p_color varchar(11) not null, 29 | p_type varchar(25) not null, 30 | p_size integer not null, 31 | p_container char(10) not null, 32 | primary key (p_partkey) 33 | ); 34 | 35 | create table supplier ( 36 | s_suppkey integer not null, 37 | s_name char(25) not null, 38 | s_address varchar(25) not null, 39 | s_city integer not null, 40 | s_nation integer not null, 41 | s_region integer not null, 42 | s_phone char(15) not null, 43 | primary key (s_suppkey) 44 | ); 45 | 46 | create table customer ( 47 | c_custkey integer not null, 48 | c_name varchar(25) not null, 49 | c_address varchar(25) not null, 50 | c_city integer not null, 51 | c_nation integer not null, 52 | c_region integer not null, 53 | c_phone char(15) not null, 54 | c_mktsegment char(10) not null, 55 | primary key (c_custkey) 56 | ); 57 | 58 | create table ddate ( 59 | d_datekey integer not null, 60 | d_date char(18) not null, 61 | d_dayofweek char(9) not null, 62 | d_month char(9) not null, 63 | d_year integer not null, 64 | d_yearmonthnum integer not null, 65 | d_yearmonth char(7) not null, 66 | d_daynuminweek integer not null, 67 | d_daynuminmonth integer not null, 68 | d_daynuminyear integer not null, 69 | d_monthnuminyear integer not null, 70 | d_weeknuminyear integer not null, 71 | d_sellingseasin varchar(12) not null, 72 | d_lastdayinweekfl integer not null, 73 | d_lastdayinmonthfl integer not null, 74 | d_holidayfl integer not null, 75 | d_weekdayfl integer not null, 76 | primary key (d_datekey) 77 | ); 78 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/ssb/queries/transformed/schema_no_pk.sql: -------------------------------------------------------------------------------- 1 | create table lineorder ( 2 | lo_orderkey integer not null, 3 | lo_linenumber integer not null, 4 | lo_custkey integer not null, 5 | lo_partkey integer not null, 6 | lo_suppkey integer not null, 7 | lo_orderdate integer not null, 8 | lo_orderpriority char(15) not null, 9 | lo_shippriority char(1) not null, 10 | lo_quantity integer not null, 11 | lo_extendedprice float not null, 12 | lo_ordtotalprice float not null, 13 | lo_discount float not null, 14 | lo_revenue float not null, 15 | lo_supplycost float not null, 16 | lo_tax integer not null, 17 | lo_commitdate integer not null, 18 | lo_shopmode char(10) not null 19 | ); 20 | 21 | create table part ( 22 | p_partkey integer not null, 23 | p_name varchar(22) not null, 24 | p_mfgr integer not null, 25 | p_category integer not null, 26 | p_brand1 integer not null, 27 | p_color varchar(11) not null, 28 | p_type varchar(25) not null, 29 | p_size integer not null, 30 | p_container char(10) not null 31 | ); 32 | 33 | create table supplier ( 34 | s_suppkey integer not null, 35 | s_name char(25) not null, 36 | s_address varchar(25) not null, 37 | s_city integer not null, 38 | s_nation integer not null, 39 | s_region integer not null, 40 | s_phone char(15) not null 41 | ); 42 | 43 | create table customer ( 44 | c_custkey integer not null, 45 | c_name varchar(25) not null, 46 | c_address varchar(25) not null, 47 | c_city integer not null, 48 | c_nation integer not null, 49 | c_region integer not null, 50 | c_phone char(15) not null, 51 | c_mktsegment char(10) not null 52 | ); 53 | 54 | create table ddate ( 55 | d_datekey integer not null, 56 | d_date char(18) not null, 57 | d_dayofweek char(9) not null, 58 | d_month char(9) not null, 59 | d_year integer not null, 60 | d_yearmonthnum integer not null, 61 | d_yearmonth char(7) not null, 62 | d_daynuminweek integer not null, 63 | d_daynuminmonth integer not null, 64 | d_daynuminyear integer not null, 65 | d_monthnuminyear integer not null, 66 | d_weeknuminyear integer not null, 67 | d_sellingseasin varchar(12) not null, 68 | d_lastdayinweekfl integer not null, 69 | d_lastdayinmonthfl integer not null, 70 | d_holidayfl integer not null, 71 | d_weekdayfl integer not null 72 | ); 73 | -------------------------------------------------------------------------------- /crystal/crystal_src/test/util.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import os 3 | 4 | class cd: 5 | """Context manager for changing the current working directory""" 6 | def __init__(self, newPath): 7 | self.newPath = os.path.expanduser(newPath) 8 | 9 | def __enter__(self): 10 | self.savedPath = os.getcwd() 11 | os.chdir(self.newPath) 12 | 13 | def __exit__(self, etype, value, traceback): 14 | os.chdir(self.savedPath) 15 | 16 | def gen_data(dataset, scale_factor): 17 | path = './' + dataset + '/dbgen/' 18 | with cd(path): 19 | os.system('rm -rf *.tbl') 20 | os.system('./dbgen -s %d -T a' % scale_factor) 21 | os.system('mkdir -p ../data/s%d' % scale_factor) 22 | os.system('mv *.tbl ../data/s%d/' % scale_factor) 23 | 24 | def transform(dataset, scale_factor): 25 | path = './' + dataset + '/loader/' 26 | ip = '../data/s%d/' % scale_factor 27 | op = '../data/s%d_columnar/' % scale_factor 28 | with cd(path): 29 | os.system('mkdir -p %s' % op) 30 | os.system('python convert.py ../data/s%d/' % scale_factor) 31 | os.system('./loader --lineorder %s/lineorder.tbl --ddate %s/date.tbl --customer %s/customer.tbl.p --supplier %s/supplier.tbl.p --part %s/part.tbl.p --datadir %s' % (ip, ip, ip, ip, ip, op)) 32 | 33 | if __name__ == "__main__": 34 | parser = argparse.ArgumentParser(description = 'data gen') 35 | parser.add_argument('dataset', type=str, choices=['ssb']) 36 | parser.add_argument('scale_factor', type=int) 37 | parser.add_argument('action', type=str, choices=['gen', 'transform']) 38 | args = parser.parse_args() 39 | 40 | if args.action == 'gen': 41 | gen_data(args.dataset, args.scale_factor) 42 | elif args.action == 'transform': 43 | transform(args.dataset, args.scale_factor) 44 | 45 | -------------------------------------------------------------------------------- /crystal/readme.md: -------------------------------------------------------------------------------- 1 | # Installation Instruction 2 | 3 | Crystal query can be compiled following the original crystal library instruction. -------------------------------------------------------------------------------- /crystal/run_query.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import time 5 | import glob 6 | import argparse 7 | import subprocess as subp 8 | 9 | from utility.profiler_logger import LOGGER 10 | 11 | 12 | def modify_scale_factor(sf, is_opt_version=False): 13 | path = "crystal-opt_src" if is_opt_version else "crystal_src" 14 | 15 | file_line_list = [] 16 | with open(f"./crystal/{path}/src/ssb/ssb_utils.h", "r") as f: 17 | for line in f.read().splitlines(): 18 | if "#define SF" in line: 19 | line = "#define SF {}".format(sf) 20 | file_line_list.append(line) 21 | 22 | with open(f"./crystal/{path}/src/ssb/ssb_utils.h", "w") as f: 23 | f.write("\n".join(file_line_list)) 24 | 25 | 26 | def recompile(is_opt_version=False): 27 | path = "crystal-opt_src" if is_opt_version else "crystal_src" 28 | 29 | os.chdir(f"./crystal/{path}/") 30 | 31 | out, _ = subp.Popen( 32 | ["make"], 33 | stdin=subp.PIPE, 34 | stdout=subp.PIPE, 35 | stderr=subp.STDOUT, 36 | ).communicate() 37 | 38 | for qnum in [11, 12, 13, 21, 22, 23, 31, 32, 33, 34, 41, 42, 43]: 39 | if os.path.exists(f"./bin/ssb/q{qnum}"): 40 | os.remove(f"./bin/ssb/q{qnum}") 41 | out, _ = subp.Popen( 42 | [ 43 | "make", 44 | f"bin/ssb/q{qnum}", 45 | ], 46 | stdin=subp.PIPE, 47 | stdout=subp.PIPE, 48 | stderr=subp.STDOUT, 49 | ).communicate() 50 | os.chdir("../../") 51 | print(out.decode("utf-8")) 52 | 53 | 54 | def run(cmd, run): 55 | exec_cmd = f"{cmd} --t={run}" 56 | out, _ = subp.Popen( 57 | exec_cmd.split(" "), 58 | stdin=subp.PIPE, 59 | stdout=subp.PIPE, 60 | stderr=subp.STDOUT, 61 | env=os.environ.copy(), 62 | ).communicate() 63 | 64 | out = out.decode("utf-8") 65 | print(out) 66 | 67 | 68 | def run_ncu(cmd, run): 69 | exec_cmd = f"{cmd} --t={run}" 70 | out, _ = subp.Popen( 71 | [ 72 | "./utility/ncu_profiler.py", 73 | f"--bin='{exec_cmd}'", 74 | ], 75 | stdin=subp.PIPE, 76 | stdout=subp.PIPE, 77 | stderr=subp.STDOUT, 78 | env=os.environ.copy(), 79 | ).communicate() 80 | 81 | out = out.decode("utf-8") 82 | print(out) 83 | 84 | 85 | def main(): 86 | parser = argparse.ArgumentParser() 87 | parser.add_argument( 88 | "--bin", type=str, required=True, help="Binary executable." 89 | ) 90 | parser.add_argument( 91 | "--profile-run", type=int, required=True, help="Profling trial." 92 | ) 93 | parser.add_argument( 94 | "--sf", type=int, default=1, help="Scale factor for benchmarking." 95 | ) 96 | parser.add_argument( 97 | "--ncu", default=False, action="store_true", help="Run Ncu profiling." 98 | ) 99 | args = parser.parse_args() 100 | 101 | with open("./.log/profiler.log", "w") as f: 102 | f.close() 103 | 104 | LOGGER.debug("Delete old report") 105 | for name in glob.glob("gpudb-perf.*"): 106 | os.remove(name) 107 | 108 | is_opt_version = "crystal-opt_src" in args.bin 109 | modify_scale_factor(args.sf, is_opt_version=is_opt_version) 110 | recompile(is_opt_version=is_opt_version) 111 | 112 | cmd = args.bin.strip("'") 113 | 114 | if args.ncu: 115 | run_ncu(cmd, 1) 116 | else: 117 | run(cmd, args.profile_run) 118 | 119 | 120 | if __name__ == "__main__": 121 | main() 122 | -------------------------------------------------------------------------------- /data/Makefile: -------------------------------------------------------------------------------- 1 | all: generate_data 2 | 3 | generate_data: generate_data.o 4 | g++ -std=c++17 generate_data.o -o generate_data 5 | 6 | generate_data.o: generate_data.cpp -------------------------------------------------------------------------------- /data/convert_all_to_parquet.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | 3 | import os 4 | import pandas as pd 5 | import subprocess as subp 6 | 7 | 8 | def main(): 9 | data_dir = "./data/storage" 10 | for path in os.listdir(data_dir): 11 | if not ".txt" in path: 12 | continue 13 | 14 | name = path.split(".")[0] 15 | print(name, "...") 16 | p = subp.Popen( 17 | [ 18 | "./data/convert_to_parquet.py", 19 | "--in-path", 20 | os.path.join(data_dir, name + ".txt"), 21 | "--out-path", 22 | os.path.join(data_dir, name + ".parquet"), 23 | ], 24 | stdin=subp.PIPE, 25 | stdout=subp.PIPE, 26 | stderr=subp.STDOUT, 27 | ) 28 | print(p.communicate()[0].decode("utf-8")) 29 | 30 | 31 | if __name__ == "__main__": 32 | main() 33 | -------------------------------------------------------------------------------- /data/convert_to_parquet.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | 3 | import pandas as pd 4 | import argparse 5 | 6 | 7 | def main(): 8 | parser = argparse.ArgumentParser() 9 | parser.add_argument( 10 | "--in-path", type=str, required=True, help="Input file path." 11 | ) 12 | parser.add_argument( 13 | "--out-path", type=str, required=True, help="Output file path." 14 | ) 15 | args = parser.parse_args() 16 | 17 | df = pd.read_csv(args.in_path) 18 | df.to_parquet(args.out_path) 19 | 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /data/generate_data.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void uniform_random(std::vector &vec, int num, int max) { 9 | std::random_device rd; 10 | std::mt19937 gen(rd()); 11 | std::uniform_int_distribution<> distr(1, max); 12 | 13 | for (int i = 0; i < num; i++) { 14 | vec.push_back(distr(gen)); 15 | } 16 | } 17 | 18 | void flush_txt(std::vector &k_vec, std::vector &v_vec) { 19 | std::ofstream of; 20 | of.open("temp.txt", std::ios::out); 21 | 22 | of << "pk,attr\n"; 23 | for (int i = 0; i < k_vec.size(); i++) { 24 | of << k_vec[i] << "," << v_vec[i] << "\n"; 25 | } 26 | of.close(); 27 | } 28 | 29 | void flush_bin(std::vector &k_vec, std::vector &v_vec) { 30 | std::ofstream of0; 31 | of0.open("temp0.bin", std::ios::out | std::ios::binary); 32 | of0.write(reinterpret_cast(&k_vec[0]), k_vec.size() * sizeof(int)); 33 | of0.close(); 34 | 35 | std::ofstream of1; 36 | of1.open("temp1.bin", std::ios::out | std::ios::binary); 37 | of1.write(reinterpret_cast(&v_vec[0]), v_vec.size() * sizeof(int)); 38 | of1.close(); 39 | 40 | // load vector to verify 41 | // std::vector in_vec(k_vec.size()); 42 | // std::ifstream if0; 43 | // if0.open("temp0.bin", std::ios::in | std::ios::binary); 44 | // if0.read(reinterpret_cast(&in_vec[0]), in_vec.size() * sizeof(int)); 45 | // if0.close(); 46 | // for (int i = 0; i < in_vec.size(); i++) { 47 | // assert(in_vec[i] == k_vec[i]); 48 | // } 49 | } 50 | 51 | int main(int argc, char **argv) { 52 | if (argc != 4) { 53 | std::cout << "./generate_data " 54 | << std::endl; 55 | exit(1); 56 | } 57 | 58 | int num = std::stoi(argv[1]), max = std::stoi(argv[2]), 59 | dist = std::stoi(argv[3]); 60 | 61 | std::cout << "Generate data: " << num << " " << max << " " << dist 62 | << std::endl; 63 | 64 | std::vector k_vec, v_vec; 65 | 66 | if (dist == 0) { 67 | uniform_random(k_vec, num, max); 68 | uniform_random(v_vec, num, max); 69 | } 70 | 71 | // std::cout << k_vec.size() << std::endl; 72 | 73 | flush_txt(k_vec, v_vec); 74 | flush_bin(k_vec, v_vec); 75 | } -------------------------------------------------------------------------------- /data/ssbm/conversion/Makefile: -------------------------------------------------------------------------------- 1 | loader: load_modified.c 2 | gcc -o loader load_modified.c 3 | 4 | original_loader: load.c 5 | gcc -o gpuDBLoader load.c 6 | 7 | sort: columnSort.c 8 | gcc -o columnSort columnSort.c -std=c99 9 | 10 | rle: rle.c 11 | gcc -std=c99 rle.c -o rleCompression 12 | 13 | dict: dict.c 14 | gcc -std=c99 dict.c -o dictCompression 15 | 16 | clean: 17 | rm -rf *.o gpuDBLoader columnSort rleCompression dictCompression 18 | -------------------------------------------------------------------------------- /data/ssbm/conversion/convert.py: -------------------------------------------------------------------------------- 1 | nations = """ALGERIA 2 | ARGENTINA 3 | BRAZIL 4 | CANADA 5 | EGYPT 6 | ETHIOPIA 7 | FRANCE 8 | GERMANY 9 | INDIA 10 | INDONESIA 11 | IRAN 12 | IRAQ 13 | JAPAN 14 | JORDAN 15 | KENYA 16 | MOROCCO 17 | MOZAMBIQUE 18 | PERU 19 | CHINA 20 | ROMANIA 21 | SAUDI ARABIA 22 | VIETNAM 23 | RUSSIA 24 | UNITED KINGDOM 25 | UNITED STATES""" 26 | 27 | # 25 nations 28 | nations = nations.split('\n') 29 | 30 | 31 | import argparse 32 | 33 | # 5 regions 34 | regions = """AFRICA 35 | AMERICA 36 | ASIA 37 | EUROPE 38 | MIDDLE EAST""" 39 | regions = regions.split('\n') 40 | 41 | if __name__ == '__main__': 42 | parser = argparse.ArgumentParser(description = 'convert') 43 | parser.add_argument('data_directory', type=str, help='Data Directory') 44 | args = parser.parse_args() 45 | 46 | data_dir = args.data_directory 47 | # process suppliers 48 | lines = open(data_dir + 'supplier.tbl').readlines() 49 | o = [] 50 | for line in lines: 51 | try: 52 | parts = line.split('|') 53 | parts[4] = str(nations.index(parts[4])) 54 | parts[5] = str(regions.index(parts[5])) 55 | parts[3] = str(int(parts[4]) * 10 + int(parts[3][-1])) 56 | o.append('|'.join(parts)) 57 | except: 58 | print(line) 59 | break 60 | 61 | f = open(data_dir + 'supplier.tbl.p','w') 62 | for line in o: 63 | f.write(line) 64 | f.close() 65 | 66 | # process customers 67 | lines = open(data_dir + 'customer.tbl').readlines() 68 | o = [] 69 | for line in lines: 70 | try: 71 | parts = line.split('|') 72 | parts[4] = str(nations.index(parts[4])) 73 | parts[5] = str(regions.index(parts[5])) 74 | parts[3] = str(int(parts[4]) * 10 + int(parts[3][-1])) 75 | o.append('|'.join(parts)) 76 | except: 77 | print(line) 78 | break 79 | 80 | f = open(data_dir + 'customer.tbl.p','w') 81 | for line in o: 82 | f.write(line) 83 | f.close() 84 | 85 | # process parts 86 | lines = open(data_dir + 'part.tbl').readlines() 87 | o = [] 88 | for line in lines: 89 | try: 90 | parts = line.split('|') 91 | parts[2] = int(parts[2].split('#')[-1]) - 1 92 | parts[3] = parts[2] * 5 + ((int(parts[3].split('#')[-1]) % 10) - 1) 93 | parts[4] = parts[3] * 40 + ((int(parts[4].split('#')[-1][2:])) - 1) 94 | parts[2] = str(parts[2]) 95 | parts[3] = str(parts[3]) 96 | parts[4] = str(parts[4]) 97 | o.append('|'.join(parts)) 98 | except: 99 | print(line) 100 | break 101 | 102 | f = open(data_dir + 'part.tbl.p','w') 103 | for line in o: 104 | f.write(line) 105 | f.close() 106 | 107 | -------------------------------------------------------------------------------- /data/ssbm/conversion/convert_old.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import argparse 3 | 4 | nations = """ALGERIA 5 | ARGENTINA 6 | BRAZIL 7 | CANADA 8 | EGYPT 9 | ETHIOPIA 10 | FRANCE 11 | GERMANY 12 | INDIA 13 | INDONESIA 14 | IRAN 15 | IRAQ 16 | JAPAN 17 | JORDAN 18 | KENYA 19 | MOROCCO 20 | MOZAMBIQUE 21 | PERU 22 | CHINA 23 | ROMANIA 24 | SAUDI ARABIA 25 | VIETNAM 26 | RUSSIA 27 | UNITED KINGDOM 28 | UNITED STATES 29 | """ 30 | nations = nations.split('\n') 31 | 32 | regions = """AFRICA 33 | AMERICA 34 | ASIA 35 | EUROPE 36 | MIDDLE EAST 37 | """ 38 | regions = regions.split('\n') 39 | 40 | if __name__ == '__main__': 41 | parser = argparse.ArgumentParser(description = 'convert') 42 | parser.add_argument('data_directory', type=str, help='Data Directory') 43 | args = parser.parse_args() 44 | 45 | data_dir = args.data_directory 46 | # process suppliers 47 | lines = open(data_dir + 'supplier.tbl').readlines() 48 | o = [] 49 | for line in lines: 50 | try: 51 | parts = line.split('|') 52 | parts[4] = str(nations.index(parts[4])) 53 | parts[5] = str(regions.index(parts[5])) 54 | parts[3] = str(int(parts[4]) * 10 + int(parts[3][-1])) 55 | o.append('|'.join(parts)) 56 | except: 57 | print(line) 58 | break 59 | 60 | f = open(data_dir + 'supplier.tbl.p','w') 61 | for line in o: 62 | f.write(line) 63 | f.close() 64 | 65 | # process customers 66 | lines = open(data_dir + 'customer.tbl').readlines() 67 | o = [] 68 | for line in lines: 69 | try: 70 | parts = line.split('|') 71 | parts[4] = str(nations.index(parts[4])) 72 | parts[5] = str(regions.index(parts[5])) 73 | parts[3] = str(int(parts[4]) * 10 + int(parts[3][-1])) 74 | o.append('|'.join(parts)) 75 | except: 76 | print(line) 77 | break 78 | 79 | f = open(data_dir + 'customer.tbl.p','w') 80 | for line in o: 81 | f.write(line) 82 | f.close() 83 | 84 | # process parts 85 | lines = open(data_dir + 'part.tbl').readlines() 86 | o = [] 87 | for line in lines: 88 | try: 89 | parts = line.split('|') 90 | parts[2] = parts[2].split('#')[-1] 91 | parts[3] = parts[3].split('#')[-1] 92 | parts[4] = parts[4].split('#')[-1] 93 | o.append('|'.join(parts)) 94 | except: 95 | print(line) 96 | break 97 | 98 | f = open(data_dir + 'part.tbl.p','w') 99 | for line in o: 100 | f.write(line) 101 | f.close() 102 | 103 | -------------------------------------------------------------------------------- /data/ssbm/conversion/include/schema.h: -------------------------------------------------------------------------------- 1 | /* This file is generated by code_gen.py */ 2 | #ifndef __SCHEMA_H__ 3 | #define __SCHEMA_H__ 4 | struct supplier { 5 | int s_suppkey; 6 | char s_name[25]; 7 | char s_address[25]; 8 | char s_city[10]; 9 | char s_nation[15]; 10 | char s_region[12]; 11 | char s_phone[15]; 12 | }; 13 | 14 | struct customer { 15 | int c_custkey; 16 | char c_name[25]; 17 | char c_address[25]; 18 | char c_city[10]; 19 | char c_nation[15]; 20 | char c_region[12]; 21 | char c_phone[15]; 22 | char c_mktsegment[10]; 23 | }; 24 | 25 | struct part { 26 | int p_partkey; 27 | char p_name[22]; 28 | char p_mfgr[6]; 29 | char p_category[7]; 30 | char p_brand1[9]; 31 | char p_color[11]; 32 | char p_type[25]; 33 | int p_size; 34 | char p_container[10]; 35 | }; 36 | 37 | struct ddate { 38 | int d_datekey; 39 | char d_date[18]; 40 | char d_dayofweek[8]; 41 | char d_month[9]; 42 | int d_year; 43 | int d_yearmonthnum; 44 | char d_yearmonth[7]; 45 | int d_daynuminweek; 46 | int d_daynuminmonth; 47 | int d_daynuminyear; 48 | int d_monthnuminyear; 49 | int d_weeknuminyear; 50 | char d_sellingseason[12]; 51 | char d_lastdayinweekfl[1]; 52 | char d_lastdayinmonthfl[1]; 53 | char d_holidayfl[1]; 54 | char d_weekdayfl[1]; 55 | }; 56 | 57 | struct lineorder { 58 | int lo_orderkey; 59 | int lo_linenumber; 60 | int lo_custkey; 61 | int lo_partkey; 62 | int lo_suppkey; 63 | int lo_orderdate; 64 | char lo_orderpriority[16]; 65 | char lo_shippriority[1]; 66 | int lo_quantity; 67 | int lo_extendedprice; 68 | int lo_ordtotalprice; 69 | int lo_discount; 70 | int lo_revenue; 71 | int lo_supplycost; 72 | int lo_tax; 73 | int lo_commitdate; 74 | char lo_shipmode[10]; 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /data/ssbm/conversion/loader: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiashenC/gpudb-char-and-opt/0395d20abdc50ae07f3d90e9dc4ddc18c2759e29/data/ssbm/conversion/loader -------------------------------------------------------------------------------- /data/ssbm/conversion/soa.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2013 The Ohio State University. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "../include/common.h" 26 | 27 | /* 28 | * Transform the column stored string from AOS to SOA. 29 | * Currently the column must be stored in an uncompressed format. 30 | */ 31 | 32 | int main(int argc, char **argv){ 33 | int fd; 34 | char * buf; 35 | 36 | if (argc != 3){ 37 | printf("./soa columnName columnWidth\n"); 38 | exit(-1); 39 | } 40 | 41 | int columnWidth = atoi(argv[2]); 42 | 43 | fd = open(argv[1], O_RDWR); 44 | 45 | struct columnHeader header; 46 | 47 | read(fd, &header, sizeof(struct columnHeader)); 48 | 49 | if (header.format != UNCOMPRESSED){ 50 | printf("Not support uncompressed column yet!"); 51 | exit(-1); 52 | } 53 | 54 | int blockTotal = header.blockTotal; 55 | 56 | long offset = 0; 57 | long tupleOffset = 0; 58 | for(int i=0;iC/C++>CommandLine, additional options: 10 | /D "SSBM" /D "DBNAME" /D "DB2" (for DB2) 11 | Building using makefile_win: set for DB2 build: 12 | nmake -f makefile_win 13 | (Change DATABASE symbol for other database) 14 | 15 | SSBM dbgen readme: 16 | 17 | SSBM is based on TPC-H dbgen source. The coding style and architecture 18 | follows the TPCH dbgen. The original TPCH dbgen code stays untouched and 19 | all new code related to SSBM dbgen follow the "#ifdef SSBM" statements. 20 | 21 | For original detailed TPC-H documentation, please refer TPCH_README 22 | document under the same directory. Here we just list few things that 23 | are specific to SSBM. 24 | 25 | 26 | 1. How is SSBM DBGEN built? 27 | 28 | Same idea as TPCH dbgen setup, which requires user to create an 29 | appropriate makefile, using makefile.suite as a basis. Make sure to 30 | use "SSBM" for the workload variable. 31 | 32 | Type "make" to compile and to generate the SSBM dbgen executable. 33 | Please refer to Porting.Notes for more details and for 34 | suggested compile time options. 35 | 36 | Note: If you want to generate the data files to a diffent directory, you should 37 | copy the dbgen executable as well as the dists.dss file to that directory. 38 | 39 | 2. How to generate SSBM data files? 40 | To generate the dimension tables: 41 | 42 | (customer.tbl) 43 | dbgen -s 1 -T c 44 | 45 | (part.tbl) 46 | dbgen -s 1 -T p 47 | 48 | (supplier.tbl) 49 | dbgen -s 1 -T s 50 | 51 | (date.tbl) 52 | dbgen -s 1 -T d 53 | 54 | (fact table lineorder.tbl) 55 | dbgen -s 1 -T l 56 | 57 | (for all SSBM tables) 58 | dbgen -s 1 -T a 59 | 60 | To generate the refresh (insert/delete) data set: 61 | (create delete.[1-4] and lineorder.tbl.u[1-4] with refreshing fact 0.05%) 62 | dbgen -s 1 -r 5 -U 4 63 | 64 | where "-r 5" specifies refreshin fact n/10000 65 | "-U 4" specifies 4 segments for deletes and inserts 66 | 67 | At this moment there is no QGEN for SSBM. So 68 | the command line options related to those features won't apply. 69 | 70 | 3. What are the changes upon TPC-H dbgen 71 | 72 | changes made upon original TPC-H dbgen 73 | 74 | 1. removed snowflake tables such as nation and region (done) 75 | 2. removed the partsupply table (done) 76 | 3. removed the order table (done) 77 | 4. renamed the fact table as Lineorder and added/removed many fields 78 | ( done) 79 | 5. added the date dimension table (done) 80 | 6. adding and removing fields in dimension tables (done) 81 | 7. have data cross reference for supplycost, revenue in lineorder (done) 82 | 8. apply the refreshing only to lineorder table (done) 83 | 84 | The command line option keeps the same as TPC-H dbgen (The -T options 85 | are changed to reflect different set of tables) 86 | 87 | ===================== End of README ======================================== 88 | 89 | -------------------------------------------------------------------------------- /data/ssbm/ssbm_src/bcd2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sccsid: @(#)bcd2.h 2.1.8.1 3 | */ 4 | int bin_bcd2(long binary, long *low_res, long *high_res); 5 | int bcd2_bin(long *dest, long bcd); 6 | int bcd2_add(long *bcd_low, long *bcd_high, long addend); 7 | int bcd2_sub(long *bcd_low, long *bcd_high, long subend); 8 | int bcd2_mul(long *bcd_low, long *bcd_high, long multiplier); 9 | int bcd2_div(long *bcd_low, long *bcd_high, long divisor); 10 | long bcd2_mod(long *bcd_low, long *bcd_high, long modulo); 11 | long bcd2_cmp(long *bcd_low, long *bcd_high, long compare); 12 | -------------------------------------------------------------------------------- /data/ssbm/ssbm_src/build.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiashenC/gpudb-char-and-opt/0395d20abdc50ae07f3d90e9dc4ddc18c2759e29/data/ssbm/ssbm_src/build.c -------------------------------------------------------------------------------- /data/ssbm/ssbm_src/dss.ddl: -------------------------------------------------------------------------------- 1 | -- Sccsid: @(#)dss.ddl 2.1.8.1 2 | CREATE TABLE TPCD.NATION ( N_NATIONKEY INTEGER NOT NULL, 3 | N_NAME CHAR(25) NOT NULL, 4 | N_REGIONKEY INTEGER NOT NULL, 5 | N_COMMENT VARCHAR(152)); 6 | 7 | CREATE TABLE TPCD.REGION ( R_REGIONKEY INTEGER NOT NULL, 8 | R_NAME CHAR(25) NOT NULL, 9 | R_COMMENT VARCHAR(152)); 10 | 11 | CREATE TABLE TPCD.PART ( P_PARTKEY INTEGER NOT NULL, 12 | P_NAME VARCHAR(55) NOT NULL, 13 | P_MFGR CHAR(25) NOT NULL, 14 | P_BRAND CHAR(10) NOT NULL, 15 | P_TYPE VARCHAR(25) NOT NULL, 16 | P_SIZE INTEGER NOT NULL, 17 | P_CONTAINER CHAR(10) NOT NULL, 18 | P_RETAILPRICE DECIMAL(15,2) NOT NULL, 19 | P_COMMENT VARCHAR(23) NOT NULL ); 20 | 21 | CREATE TABLE TPCD.SUPPLIER ( S_SUPPKEY INTEGER NOT NULL, 22 | S_NAME CHAR(25) NOT NULL, 23 | S_ADDRESS VARCHAR(40) NOT NULL, 24 | S_NATIONKEY INTEGER NOT NULL, 25 | S_PHONE CHAR(15) NOT NULL, 26 | S_ACCTBAL DECIMAL(15,2) NOT NULL, 27 | S_COMMENT VARCHAR(101) NOT NULL); 28 | 29 | CREATE TABLE TPCD.PARTSUPP ( PS_PARTKEY INTEGER NOT NULL, 30 | PS_SUPPKEY INTEGER NOT NULL, 31 | PS_AVAILQTY INTEGER NOT NULL, 32 | PS_SUPPLYCOST DECIMAL(15,2) NOT NULL, 33 | PS_COMMENT VARCHAR(199) NOT NULL ); 34 | 35 | CREATE TABLE TPCD.CUSTOMER ( C_CUSTKEY INTEGER NOT NULL, 36 | C_NAME VARCHAR(25) NOT NULL, 37 | C_ADDRESS VARCHAR(40) NOT NULL, 38 | C_NATIONKEY INTEGER NOT NULL, 39 | C_PHONE CHAR(15) NOT NULL, 40 | C_ACCTBAL DECIMAL(15,2) NOT NULL, 41 | C_MKTSEGMENT CHAR(10) NOT NULL, 42 | C_COMMENT VARCHAR(117) NOT NULL); 43 | 44 | CREATE TABLE TPCD.ORDERS ( O_ORDERKEY INTEGER NOT NULL, 45 | O_CUSTKEY INTEGER NOT NULL, 46 | O_ORDERSTATUS CHAR(1) NOT NULL, 47 | O_TOTALPRICE DECIMAL(15,2) NOT NULL, 48 | O_ORDERDATE DATE NOT NULL, 49 | O_ORDERPRIORITY CHAR(15) NOT NULL, -- R 50 | O_CLERK CHAR(15) NOT NULL, -- R 51 | O_SHIPPRIORITY INTEGER NOT NULL, 52 | O_COMMENT VARCHAR(79) NOT NULL); 53 | 54 | CREATE TABLE TPCD.LINEITEM ( L_ORDERKEY INTEGER NOT NULL, 55 | L_PARTKEY INTEGER NOT NULL, 56 | L_SUPPKEY INTEGER NOT NULL, 57 | L_LINENUMBER INTEGER NOT NULL, 58 | L_QUANTITY DECIMAL(15,2) NOT NULL, 59 | L_EXTENDEDPRICE DECIMAL(15,2) NOT NULL, 60 | L_DISCOUNT DECIMAL(15,2) NOT NULL, 61 | L_TAX DECIMAL(15,2) NOT NULL, 62 | L_RETURNFLAG CHAR(1) NOT NULL, 63 | L_LINESTATUS CHAR(1) NOT NULL, 64 | L_SHIPDATE DATE NOT NULL, 65 | L_COMMITDATE DATE NOT NULL, 66 | L_RECEIPTDATE DATE NOT NULL, 67 | L_SHIPINSTRUCT CHAR(25) NOT NULL, -- R 68 | L_SHIPMODE CHAR(10) NOT NULL, -- R 69 | L_COMMENT VARCHAR(44) NOT NULL); 70 | 71 | -------------------------------------------------------------------------------- /data/ssbm/ssbm_src/dss.ri: -------------------------------------------------------------------------------- 1 | -- Sccsid: @(#)dss.ri 2.1.8.1 2 | -- TPCD Benchmark Version 8.0 3 | 4 | CONNECT TO TPCD; 5 | 6 | --ALTER TABLE TPCD.REGION DROP PRIMARY KEY; 7 | --ALTER TABLE TPCD.NATION DROP PRIMARY KEY; 8 | --ALTER TABLE TPCD.PART DROP PRIMARY KEY; 9 | --ALTER TABLE TPCD.SUPPLIER DROP PRIMARY KEY; 10 | --ALTER TABLE TPCD.PARTSUPP DROP PRIMARY KEY; 11 | --ALTER TABLE TPCD.ORDERS DROP PRIMARY KEY; 12 | --ALTER TABLE TPCD.LINEITEM DROP PRIMARY KEY; 13 | --ALTER TABLE TPCD.CUSTOMER DROP PRIMARY KEY; 14 | 15 | 16 | -- For table REGION 17 | ALTER TABLE TPCD.REGION 18 | ADD PRIMARY KEY (R_REGIONKEY); 19 | 20 | -- For table NATION 21 | ALTER TABLE TPCD.NATION 22 | ADD PRIMARY KEY (N_NATIONKEY); 23 | 24 | ALTER TABLE TPCD.NATION 25 | ADD FOREIGN KEY NATION_FK1 (N_REGIONKEY) references TPCD.REGION; 26 | 27 | COMMIT WORK; 28 | 29 | -- For table PART 30 | ALTER TABLE TPCD.PART 31 | ADD PRIMARY KEY (P_PARTKEY); 32 | 33 | COMMIT WORK; 34 | 35 | -- For table SUPPLIER 36 | ALTER TABLE TPCD.SUPPLIER 37 | ADD PRIMARY KEY (S_SUPPKEY); 38 | 39 | ALTER TABLE TPCD.SUPPLIER 40 | ADD FOREIGN KEY SUPPLIER_FK1 (S_NATIONKEY) references TPCD.NATION; 41 | 42 | COMMIT WORK; 43 | 44 | -- For table PARTSUPP 45 | ALTER TABLE TPCD.PARTSUPP 46 | ADD PRIMARY KEY (PS_PARTKEY,PS_SUPPKEY); 47 | 48 | COMMIT WORK; 49 | 50 | -- For table CUSTOMER 51 | ALTER TABLE TPCD.CUSTOMER 52 | ADD PRIMARY KEY (C_CUSTKEY); 53 | 54 | ALTER TABLE TPCD.CUSTOMER 55 | ADD FOREIGN KEY CUSTOMER_FK1 (C_NATIONKEY) references TPCD.NATION; 56 | 57 | COMMIT WORK; 58 | 59 | -- For table LINEITEM 60 | ALTER TABLE TPCD.LINEITEM 61 | ADD PRIMARY KEY (L_ORDERKEY,L_LINENUMBER); 62 | 63 | COMMIT WORK; 64 | 65 | -- For table ORDERS 66 | ALTER TABLE TPCD.ORDERS 67 | ADD PRIMARY KEY (O_ORDERKEY); 68 | 69 | COMMIT WORK; 70 | 71 | -- For table PARTSUPP 72 | ALTER TABLE TPCD.PARTSUPP 73 | ADD FOREIGN KEY PARTSUPP_FK1 (PS_SUPPKEY) references TPCD.SUPPLIER; 74 | 75 | COMMIT WORK; 76 | 77 | ALTER TABLE TPCD.PARTSUPP 78 | ADD FOREIGN KEY PARTSUPP_FK2 (PS_PARTKEY) references TPCD.PART; 79 | 80 | COMMIT WORK; 81 | 82 | -- For table ORDERS 83 | ALTER TABLE TPCD.ORDERS 84 | ADD FOREIGN KEY ORDERS_FK1 (O_CUSTKEY) references TPCD.CUSTOMER; 85 | 86 | COMMIT WORK; 87 | 88 | -- For table LINEITEM 89 | ALTER TABLE TPCD.LINEITEM 90 | ADD FOREIGN KEY LINEITEM_FK1 (L_ORDERKEY) references TPCD.ORDERS; 91 | 92 | COMMIT WORK; 93 | 94 | ALTER TABLE TPCD.LINEITEM 95 | ADD FOREIGN KEY LINEITEM_FK2 (L_PARTKEY,L_SUPPKEY) references 96 | TPCD.PARTSUPP; 97 | 98 | COMMIT WORK; 99 | 100 | 101 | -------------------------------------------------------------------------------- /data/ssbm/ssbm_src/makefile_win: -------------------------------------------------------------------------------- 1 | VC="c:/Program Files/Microsoft Visual Studio 9.0/VC" 2 | WIN_INC="C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include" 3 | WIN_LIB="C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib" 4 | #VC = "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7" 5 | VCLIB = $(VC)\LIB 6 | # @(#)makefile.suite 2.1.8.1 7 | ################ 8 | ## CHANGE NAME OF ANSI COMPILER HERE 9 | ################ 10 | CC =cl.exe 11 | # Current values for DATABASE are: INFORMIX, DB2, TDAT (Teradata) 12 | # SQLSERVER, SYBASE 13 | # Current values for MACHINE are: ATT, DOS, WIN32 HP, IBM, ICL, MVS, 14 | # SGI, SUN, U2200, VMS, LINUX 15 | # Current values for WORKLOAD are: SSBM, TPCH, TPCR 16 | DATABASE=DB2 17 | MACHINE =WIN32 18 | WORKLOAD =SSBM 19 | # 20 | # add -EDTERABYTE if orderkey will execeed 32 bits (SF >= 300) 21 | # and make the appropriate change in gen_schema() of runit.sh 22 | CFLAGS = -DDBNAME=\"dss\" -D$(MACHINE) -D$(DATABASE) -D$(WORKLOAD) /I$(VC)\include /I$(WIN_INC) 23 | 24 | #LDFLAGS = -O 25 | # The OBJ,EXE and LIB macros will need to be changed for compilation under 26 | # Windows NT 27 | OBJ = .obj 28 | EXE = .exe 29 | LIBS =$(VCLIB)\libcmt.lib $(VCLIB)\oldnames.lib $(VCLIB)\oldnames.lib $(WIN_LIB)\kernel32.lib 30 | # 31 | # NO CHANGES SHOULD BE NECESSARY BELOW THIS LINE 32 | ############### 33 | # 34 | PROG1 = dbgen$(EXE) 35 | PROG2 = qgen$(EXE) 36 | PROGS = $(PROG1) $(PROG2) 37 | # 38 | HDR1 = dss.h rnd.h config.h dsstypes.h shared.h bcd2.h 39 | HDR2 = tpcd.h permute.h 40 | HDR = $(HDR1) $(HDR2) 41 | # 42 | SRC1 = build.c driver.c bm_utils.c rnd.c print.c load_stub.c bcd2.c \ 43 | speed_seed.c text.c permute.c 44 | SRC2 = qgen.c varsub.c 45 | SRC = $(SRC1) $(SRC2) 46 | # 47 | OBJ1 = build$(OBJ) driver$(OBJ) bm_utils$(OBJ) rnd$(OBJ) print$(OBJ) \ 48 | load_stub$(OBJ) bcd2$(OBJ) speed_seed$(OBJ) text$(OBJ) permute$(OBJ) 49 | OBJ2 = build$(OBJ) bm_utils$(OBJ) qgen$(OBJ) rnd$(OBJ) varsub$(OBJ) \ 50 | text$(OBJ) bcd2$(OBJ) permute$(OBJ) speed_seed$(OBJ) 51 | OBJS = $(OBJ1) $(OBJ2) 52 | # 53 | SETS = dists.dss 54 | DOC=README HISTORY PORTING.NOTES BUGS 55 | DDL = dss.ddl dss.ri 56 | OTHER=makefile.suite $(SETS) $(DDL) 57 | # case is *important* in TEST_RES 58 | TEST_RES = O.res L.res c.res s.res P.res S.res n.res r.res 59 | # 60 | DBGENSRC=$(SRC1) $(HDR1) $(OTHER) $(DOC) $(SRC2) $(HDR2) $(SRC3) 61 | QD=1.sql 2.sql 3.sql 4.sql 5.sql 6.sql 7.sql 8.sql 9.sql 10.sql \ 62 | 11.sql 12.sql 13.sql 14.sql 15.sql 16.sql 17.sql 18.sql \ 63 | 19.sql 20.sql 21.sql 22.sql 64 | VARIANTS= 8a.sql 12a.sql 13a.sql 14a.sql 15a.sql 65 | ANS = 1.ans 2.ans 3.ans 4.ans 5.ans 6.ans 7.ans 8.ans 9.ans 10.ans 11.ans \ 66 | 12.ans 13.ans 14.ans 15.ans 16.ans 17.ans 18.ans 19.ans 20.ans \ 67 | 21.ans 22.ans 68 | QSRC = $(FQD) $(VARIANTS) 69 | ALLSRC=$(DBGENSRC) 70 | TREE_DOC=tree.readme tree.changes appendix.readme appendix.version answers.readme queries.readme variants.readme 71 | JUNK = 72 | # 73 | all: $(PROGS) 74 | 75 | $(PROG1): $(OBJ1) $(SETS) 76 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ1) $(LIBS) 77 | 78 | $(PROG2): permute.h $(OBJ2) 79 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ2) $(LIBS) 80 | 81 | clean: 82 | del /F $(PROGS) $(OBJS) $(JUNK) 83 | 84 | $(OBJ1): $(HDR1) 85 | $(OBJ2): dss.h tpcd.h config.h 86 | -------------------------------------------------------------------------------- /data/ssbm/ssbm_src/permute.c: -------------------------------------------------------------------------------- 1 | /* @(#)permute.c 2.1.8.3 */ 2 | /* 3 | * permute.c -- a permutation generator for the query 4 | * sequences in TPC-H and TPC-R 5 | */ 6 | 7 | #ifdef TEST 8 | #define DECLARER 9 | #endif 10 | #include "config.h" 11 | #include "dss.h" 12 | #ifdef TEST 13 | #include 14 | #if (defined(_POSIX_)||!defined(WIN32)) /* Change for Windows NT */ 15 | #include 16 | #include 17 | #endif /* WIN32 */ 18 | #include /* */ 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #ifdef HP 26 | #include 27 | #endif 28 | #if (defined(WIN32)&&!defined(_POSIX_)) 29 | #include 30 | #pragma warning(disable:4201) 31 | #pragma warning(disable:4214) 32 | #pragma warning(disable:4514) 33 | #define WIN32_LEAN_AND_MEAN 34 | #define NOATOM 35 | #define NOGDICAPMASKS 36 | #define NOMETAFILE 37 | #define NOMINMAX 38 | #define NOMSG 39 | #define NOOPENFILE 40 | #define NORASTEROPS 41 | #define NOSCROLL 42 | #define NOSOUND 43 | #define NOSYSMETRICS 44 | #define NOTEXTMETRIC 45 | #define NOWH 46 | #define NOCOMM 47 | #define NOKANJI 48 | #define NOMCX 49 | #include 50 | #pragma warning(default:4201) 51 | #pragma warning(default:4214) 52 | #endif 53 | #endif 54 | 55 | long NextRand(long seed); 56 | long *permute(long *set, int cnt, long stream); 57 | long *permute_dist(distribution *d, long stream); 58 | long seed; 59 | char *eol[2] = {" ", "},"}; 60 | extern seed_t Seed[]; 61 | #ifdef TEST 62 | tdef tdefs = { NULL }; 63 | #endif 64 | 65 | 66 | #define MAX_QUERY 22 67 | #define ITERATIONS 1000 68 | #define UNSET 0 69 | 70 | long * 71 | permute(long *a, int c, long s) 72 | { 73 | int i; 74 | static long source; 75 | static long *set, temp; 76 | 77 | if (a != (long *)NULL) 78 | { 79 | set = a; 80 | for (i=0; i < c; i++) 81 | *(a + i) = i; 82 | for (i=0; i < c; i++) 83 | { 84 | RANDOM(source, 0L, (long)(c - 1), s); 85 | temp = *(a + source); 86 | *(a + source) = *(a + i) ; 87 | *(a + i) = temp; 88 | source = 0; 89 | } 90 | } 91 | else 92 | source += 1; 93 | 94 | if (source >= c) 95 | source -= c; 96 | 97 | return(set + source); 98 | } 99 | 100 | long * 101 | permute_dist(distribution *d, long stream) 102 | { 103 | static distribution *dist = NULL; 104 | int i; 105 | 106 | if (d != NULL) 107 | { 108 | if (d->permute == (long *)NULL) 109 | { 110 | d->permute = (long *)malloc(sizeof(long) * DIST_SIZE(d)); 111 | MALLOC_CHECK(d->permute); 112 | for (i=0; i < DIST_SIZE(d); i++) 113 | *(d->permute + i) = i; 114 | } 115 | dist = d; 116 | return(permute(dist->permute, DIST_SIZE(dist), stream)); 117 | } 118 | 119 | 120 | if (dist != NULL) 121 | return(permute(NULL, DIST_SIZE(dist), stream)); 122 | else 123 | INTERNAL_ERROR("Bad call to permute_dist"); 124 | } 125 | 126 | 127 | #ifdef TEST 128 | 129 | main(int ac, char *av[]) 130 | { 131 | long *sequence, 132 | i, 133 | j, 134 | streams = UNSET, 135 | *a; 136 | char sep; 137 | int index = 0; 138 | 139 | set_seeds = 0; 140 | sequence = (long *)malloc(MAX_QUERY * sizeof(long)); 141 | a = sequence; 142 | for (i=0; i < MAX_QUERY; i++) 143 | *(sequence + i) = i; 144 | if (ac < 3) 145 | goto usage; 146 | Seed[0].value = (long)atoi(av[1]); 147 | streams = atoi(av[2]); 148 | if (Seed[0].value == UNSET || streams == UNSET) 149 | goto usage; 150 | 151 | index = 0; 152 | printf("long permutation[%d][%d] = {\n", streams, MAX_QUERY); 153 | for (j=0; j < streams; j++) 154 | { 155 | sep = '{'; 156 | printf("%s\n", eol[index]); 157 | for (i=0; i < MAX_QUERY; i++) 158 | { 159 | printf("%c%2d", sep, *permute(a, MAX_QUERY, 0) + 1); 160 | a = (long *)NULL; 161 | sep = ','; 162 | } 163 | a = sequence; 164 | index=1; 165 | } 166 | printf("}\n};\n"); 167 | return(0); 168 | 169 | usage: 170 | printf("Usage: %s \n",av[0]); 171 | printf(" uses to start the generation of permutations of [1..%d]\n", MAX_QUERY); 172 | return(-1); 173 | 174 | } 175 | #endif /* TEST */ 176 | -------------------------------------------------------------------------------- /data/ssbm/ssbm_src/permute.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)permute.h 2.1.8.1 3 | */ 4 | long permutation[41][22] = 5 | { 6 | {14, 2, 9,20, 6,17,18, 8,21,13, 3,22,16, 4,11,15, 1,10,19, 5, 7,12}, 7 | {21, 3,18, 5,11, 7, 6,20,17,12,16,15,13,10, 2, 8,14,19, 9,22, 1, 4}, 8 | { 6,17,14,16,19,10, 9, 2,15, 8, 5,22,12, 7,13,18, 1, 4,20, 3,11,21}, 9 | { 8, 5, 4, 6,17, 7, 1,18,22,14, 9,10,15,11,20, 2,21,19,13,16,12, 3}, 10 | { 5,21,14,19,15,17,12, 6, 4, 9, 8,16,11, 2,10,18, 1,13, 7,22, 3,20}, 11 | {21,15, 4, 6, 7,16,19,18,14,22,11,13, 3, 1, 2, 5, 8,20,12,17,10, 9}, 12 | {10, 3,15,13, 6, 8, 9, 7, 4,11,22,18,12, 1, 5,16, 2,14,19,20,17,21}, 13 | {18, 8,20,21, 2, 4,22,17, 1,11, 9,19, 3,13, 5, 7,10,16, 6,14,15,12}, 14 | {19, 1,15,17, 5, 8, 9,12,14, 7, 4, 3,20,16, 6,22,10,13, 2,21,18,11}, 15 | { 8,13, 2,20,17, 3, 6,21,18,11,19,10,15, 4,22, 1, 7,12, 9,14, 5,16}, 16 | { 6,15,18,17,12, 1, 7, 2,22,13,21,10,14, 9, 3,16,20,19,11, 4, 8, 5}, 17 | {15,14,18,17,10,20,16,11, 1, 8, 4,22, 5,12, 3, 9,21, 2,13, 6,19, 7}, 18 | { 1, 7,16,17,18,22,12, 6, 8, 9,11, 4, 2, 5,20,21,13,10,19, 3,14,15}, 19 | {21,17, 7, 3, 1,10,12,22, 9,16, 6,11, 2, 4, 5,14, 8,20,13,18,15,19}, 20 | { 2, 9, 5, 4,18, 1,20,15,16,17, 7,21,13,14,19, 8,22,11,10, 3,12, 6}, 21 | {16, 9,17, 8,14,11,10,12, 6,21, 7, 3,15, 5,22,20, 1,13,19, 2, 4,18}, 22 | { 1, 3, 6, 5, 2,16,14,22,17,20, 4, 9,10,11,15, 8,12,19,18,13, 7,21}, 23 | { 3,16, 5,11,21, 9, 2,15,10,18,17, 7, 8,19,14,13, 1, 4,22,20, 6,12}, 24 | {14, 4,13, 5,21,11, 8, 6, 3,17, 2,20, 1,19,10, 9,12,18,15, 7,22,16}, 25 | { 4,12,22,14, 5,15,16, 2, 8,10,17, 9,21, 7, 3, 6,13,18,11,20,19, 1}, 26 | {16,15,14,13, 4,22,18,19, 7, 1,12,17, 5,10,20, 3, 9,21,11, 2, 6, 8}, 27 | {20,14,21,12,15,17, 4,19,13,10,11, 1,16, 5,18, 7, 8,22, 9, 6, 3, 2}, 28 | {16,14,13, 2,21,10,11, 4, 1,22,18,12,19, 5, 7, 8, 6, 3,15,20, 9,17}, 29 | {18,15, 9,14,12, 2, 8,11,22,21,16, 1, 6,17, 5,10,19, 4,20,13, 3, 7}, 30 | { 7, 3,10,14,13,21,18, 6,20, 4, 9, 8,22,15, 2, 1, 5,12,19,17,11,16}, 31 | {18, 1,13, 7,16,10,14, 2,19, 5,21,11,22,15, 8,17,20, 3, 4,12, 6, 9}, 32 | {13, 2,22, 5,11,21,20,14, 7,10, 4, 9,19,18, 6, 3, 1, 8,15,12,17,16}, 33 | {14,17,21, 8, 2, 9, 6, 4, 5,13,22, 7,15, 3, 1,18,16,11,10,12,20,19}, 34 | {10,22, 1,12,13,18,21,20, 2,14,16, 7,15, 3, 4,17, 5,19, 6, 8, 9,11}, 35 | {10, 8, 9,18,12, 6, 1, 5,20,11,17,22,16, 3,13, 2,15,21,14,19, 7, 4}, 36 | { 7,17,22, 5, 3,10,13,18, 9, 1,14,15,21,19,16,12, 8, 6,11,20, 4, 2}, 37 | { 2, 9,21, 3, 4, 7, 1,11,16, 5,20,19,18, 8,17,13,10,12,15, 6,14,22}, 38 | {15,12, 8, 4,22,13,16,17,18, 3, 7, 5, 6, 1, 9,11,21,10,14,20,19, 2}, 39 | {15,16, 2,11,17, 7, 5,14,20, 4,21, 3,10, 9,12, 8,13, 6,18,19,22, 1}, 40 | { 1,13,11, 3, 4,21, 6,14,15,22,18, 9, 7, 5,10,20,12,16,17, 8,19, 2}, 41 | {14,17,22,20, 8,16, 5,10, 1,13, 2,21,12, 9, 4,18, 3, 7, 6,19,15,11}, 42 | { 9,17, 7, 4, 5,13,21,18,11, 3,22, 1, 6,16,20,14,15,10, 8, 2,12,19}, 43 | {13,14, 5,22,19,11, 9, 6,18,15, 8,10, 7, 4,17,16, 3, 1,12, 2,21,20}, 44 | {20, 5, 4,14,11, 1, 6,16, 8,22, 7, 3, 2,12,21,19,17,13,10,15,18, 9}, 45 | { 3, 7,14,15, 6, 5,21,20,18,10, 4,16,19, 1,13, 9, 8,17,11,12,22, 2}, 46 | {13,15,17, 1,22,11, 3, 4, 7,20,14,21, 9, 8, 2,18,16, 6,10,12, 5,19} 47 | }; 48 | -------------------------------------------------------------------------------- /data/ssbm/ssbm_src/shared.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Sccsid: @(#)shared.h 2.1.8.1 3 | * Modified for SSBM 4 | */ 5 | #define N_CMNT_LEN 72 6 | #define N_CMNT_MAX 152 7 | #define R_CMNT_LEN 72 8 | #define R_CMNT_MAX 152 9 | #define MONEY_SCL 0.01 10 | #define V_STR_HGH 1.6 11 | 12 | #ifdef SSBM 13 | #define P_NAME_LEN 22 14 | #define P_MFG_LEN 6 15 | #define P_COLOR_LEN 3 16 | #define P_COLOR_MAX 11 17 | #define P_TYPE_MAX 25 18 | #define P_CAT_LEN 7 19 | #define P_CAT_MIN 1 20 | #define P_CAT_MAX 5 21 | #define P_CAT_SD 97 22 | #define S_NATION_NAME_LEN 15 23 | #define S_REGION_NAME_LEN 12 24 | #define C_NATION_NAME_LEN 15 25 | #define C_REGION_NAME_LEN 12 26 | #define C_NAT_SD 16 27 | #define C_REG_SD 3 28 | #define O_SHIP_STRU_LEN 25 29 | #define O_SHIP_MODE_LEN 10 30 | #define O_SHIP_PRIO_LEN 1 31 | #define D_DATE_LEN 18 32 | #define D_DAYWEEK_LEN 9 33 | #define D_YEARMONTH_LEN 7 34 | #define D_SEASON_LEN 12 35 | #define D_MONTH_LEN 9 36 | #define D_STARTDATE 694245661 /*corresponding to 1/1/1992 1:1:1*/ 37 | #define NAMTION_BRIEF_LEN 9 38 | #define CITY_CODE_SEED 15 39 | #define NUM_DAYS 2556 40 | #define NUM_SEASONS 5 41 | #define NUM_HOLIDAYS 10 42 | #define CITY_FIX 10 43 | #else 44 | 45 | #define P_NAME_LEN 55 46 | #define P_MFG_LEN 25 47 | 48 | #endif 49 | 50 | #define P_BRND_LEN 10 51 | 52 | #ifdef SSBM 53 | #define P_TYPE_LEN 12 54 | 55 | #else 56 | 57 | #define P_TYPE_LEN 25 58 | 59 | #endif 60 | 61 | #define P_CNTR_LEN 10 62 | #define P_CMNT_LEN 14 63 | #define P_CMNT_MAX 23 64 | #define P_CAT_SEED 25 65 | 66 | #define S_NAME_LEN 25 67 | 68 | #ifdef SSBM 69 | #define S_ADDR_LEN 15 70 | #define S_ADDR_MAX 25 71 | #else 72 | 73 | #define S_ADDR_LEN 25 74 | #define S_ADDR_MAX 40 75 | #endif 76 | 77 | #define S_CMNT_LEN 63 78 | #define S_CMNT_MAX 101 79 | #define PS_CMNT_LEN 124 80 | #define PS_CMNT_MAX 199 81 | 82 | #ifdef SSBM 83 | #define C_NAME_LEN 25 84 | #define C_MSEG_MIN 1 85 | #define C_MSEG_MAX 5 86 | #define C_ADDR_LEN 15 87 | #define C_ADDR_MAX 25 88 | #else 89 | #define C_NAME_LEN 18 90 | #define C_ADDR_LEN 25 91 | #define C_ADDR_MAX 40 92 | #endif 93 | 94 | #define C_MSEG_LEN 10 95 | #define C_CMNT_LEN 73 96 | #define C_CMNT_MAX 117 97 | 98 | #ifdef SSBM 99 | #define O_OPRIO_LEN 8 100 | 101 | #else 102 | #define O_OPRIO_LEN 15 103 | 104 | #endif 105 | 106 | #define O_CLRK_LEN 15 107 | #define O_CMNT_LEN 49 108 | #define O_CMNT_MAX 79 109 | #define L_CMNT_LEN 27 110 | #define L_CMNT_MAX 44 111 | #define L_INST_LEN 25 112 | #define L_SMODE_LEN 10 113 | #define T_ALPHA_LEN 10 114 | #define DATE_LEN 13 /* long enough to hold either date format */ 115 | #define NATION_LEN 25 116 | #define REGION_LEN 25 117 | #define PHONE_LEN 15 118 | 119 | #ifdef SSBM 120 | #define MAXAGG_LEN 32 /* max component length for a agg str */ 121 | 122 | #else 123 | #define MAXAGG_LEN 20 /* max component length for a agg str */ 124 | 125 | #endif 126 | 127 | #define P_CMNT_SD 6 128 | #define PS_CMNT_SD 9 129 | #define O_CMNT_SD 12 130 | #define C_ADDR_SD 26 131 | #define C_CMNT_SD 31 132 | #define S_ADDR_SD 32 133 | #define S_CMNT_SD 36 134 | #define L_CMNT_SD 25 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /data/ssbm/ssbm_src/tpcd.h: -------------------------------------------------------------------------------- 1 | /***************************************************************** 2 | * Title: tpcd.h for TPC D 3 | * Sccsid: @(#)tpcd.h 2.1.8.1 4 | * Description: 5 | * X 6 | * 7 | ***************************************************************** 8 | */ 9 | #define DFLT 0x0001 10 | #define OUTPUT 0x0002 11 | #define EXPLAIN 0x0004 12 | #define DBASE 0x0008 13 | #define VERBOSE 0x0010 14 | #define TIMING 0x0020 15 | #define LOG 0x0040 16 | #define QUERY 0x0080 17 | #define REFRESH 0x0100 18 | #define ANSI 0x0200 19 | #define SEED 0x0400 20 | #define COMMENT 0x0800 21 | #define INIT 0x1000 22 | #define TERMINATE 0x2000 23 | #define DFLT_NUM 0x4000 24 | 25 | /* 26 | * general defines 27 | */ 28 | #define VTAG ':' /* flags a variable substitution */ 29 | #define ofp stdout /* make the routine a filter */ 30 | #define QDIR_TAG "DSS_QUERY" /* variable to point to queries */ 31 | #define QDIR_DFLT "." /* and its default */ 32 | 33 | /* 34 | * database portability defines 35 | */ 36 | #ifdef DB2 37 | #define GEN_QUERY_PLAN "SET CURRENT EXPLAIN SNAPSHOT ON;" 38 | #define START_TRAN "" 39 | #define END_TRAN "COMMIT WORK;" 40 | #define SET_OUTPUT "" 41 | #define SET_ROWCOUNT "--#SET ROWS_FETCH %d\n" 42 | #define SET_DBASE "CONNECT TO %s ;\n" 43 | #endif 44 | 45 | #ifdef INFORMIX 46 | #define GEN_QUERY_PLAN "SET EXPLAIN ON;" 47 | #define START_TRAN "BEGIN WORK;" 48 | #define END_TRAN "COMMIT WORK;" 49 | #define SET_OUTPUT "OUTPUT TO " 50 | #define SET_ROWCOUNT "FIRST %d" 51 | #define SET_DBASE "database %s ;\n" 52 | #endif 53 | 54 | #ifdef SQLSERVER 55 | #define GEN_QUERY_PLAN "set showplan on\nset noexec on\ngo\n" 56 | #define START_TRAN "begin transaction\ngo\n" 57 | #define END_TRAN "commit transaction\ngo\n" 58 | #define SET_OUTPUT "" 59 | #define SET_ROWCOUNT "set rowcount %d\ngo\n\n" 60 | #define SET_DBASE "use %s\ngo\n" 61 | #endif 62 | 63 | #ifdef SYBASE 64 | #define GEN_QUERY_PLAN "set showplan on\nset noexec on\ngo\n" 65 | #define START_TRAN "begin transaction\ngo\n" 66 | #define END_TRAN "commit transaction\ngo\n" 67 | #define SET_OUTPUT "" 68 | #define SET_ROWCOUNT "set rowcount %d\ngo\n\n" 69 | #define SET_DBASE "use %s\ngo\n" 70 | #endif 71 | 72 | #ifdef TDAT 73 | #define GEN_QUERY_PLAN "EXPLAIN" 74 | #define START_TRAN "BEGIN TRANSACTION" 75 | #define END_TRAN "END TRANSACTION" 76 | #define SET_OUTPUT ".SET FORMAT OFF\n.EXPORT REPORT file=" 77 | #define SET_ROWCOUNT ".SET RETCANCEL ON\n.SET RETLIMIT %d\n" 78 | #define SET_DBASE ".LOGON %s\n" 79 | #endif 80 | 81 | #define MAX_VARS 8 /* max number of host vars in any query */ 82 | #define QLEN_MAX 2048 /* max length of any query */ 83 | #define QUERIES_PER_SET 22 84 | #define MAX_PIDS 50 85 | 86 | EXTERN int flags; 87 | EXTERN int s_cnt; 88 | EXTERN char *osuff; 89 | EXTERN int stream; 90 | EXTERN char *lfile; 91 | EXTERN char *ifile; 92 | EXTERN char *tfile; 93 | 94 | #define MAX_PERMUTE 41 95 | #ifdef DECLARER 96 | int rowcnt_dflt[QUERIES_PER_SET + 1] = 97 | {-1,-1,100,10,-1,-1,-1,-1,-1,-1,20,-1,-1,-1,-1,-1,-1,-1,100,-1,-1,100,-1}; 98 | int rowcnt; 99 | #define SEQUENCE(stream, query) permutation[stream % MAX_PERMUTE][query - 1] 100 | #else 101 | extern int rowcnt_dflt[]; 102 | extern int rowcnt; 103 | #endif 104 | -------------------------------------------------------------------------------- /heavydb/.gitignore: -------------------------------------------------------------------------------- 1 | .local 2 | -------------------------------------------------------------------------------- /heavydb/heavydb.conf: -------------------------------------------------------------------------------- 1 | port = 6274 2 | http-port = 6278 3 | calcite-port = 6279 4 | data = "./heavydb/heavydb_src/build/data" 5 | read-only = false 6 | verbose = false 7 | allowed-import-paths=["./data/storage"] 8 | enable-debug-timer = true 9 | 10 | [web] 11 | port = 6273 12 | frontend = "frontend" 13 | -------------------------------------------------------------------------------- /heavydb/heavydb_part0.conf: -------------------------------------------------------------------------------- 1 | port = 10000 2 | http-port = 10001 3 | calcite-port = 10002 4 | data = "./heavydb/heavydb_src/build/data-part0" 5 | read-only = false 6 | verbose = false 7 | allowed-import-paths=["./data/storage"] 8 | enable-debug-timer = true 9 | 10 | [web] 11 | port = 10003 12 | frontend = "frontend" 13 | -------------------------------------------------------------------------------- /heavydb/heavydb_part1.conf: -------------------------------------------------------------------------------- 1 | port = 20000 2 | http-port = 20001 3 | calcite-port = 20002 4 | data = "./heavydb/heavydb_src/build/data-part1" 5 | read-only = false 6 | verbose = false 7 | allowed-import-paths=["./data/storage"] 8 | enable-debug-timer = true 9 | 10 | [web] 11 | port = 20003 12 | frontend = "frontend" 13 | -------------------------------------------------------------------------------- /heavydb/heavydb_part2.conf: -------------------------------------------------------------------------------- 1 | port = 30000 2 | http-port = 30001 3 | calcite-port = 30002 4 | data = "./heavydb/heavydb_src/build/data-part2" 5 | read-only = false 6 | verbose = false 7 | allowed-import-paths=["./data/storage"] 8 | enable-debug-timer = true 9 | 10 | [web] 11 | port = 30003 12 | frontend = "frontend" 13 | -------------------------------------------------------------------------------- /heavydb/heavydb_part3.conf: -------------------------------------------------------------------------------- 1 | port = 10010 2 | http-port = 10011 3 | calcite-port = 10012 4 | data = "./heavydb/heavydb_src/build/data-part3" 5 | read-only = false 6 | verbose = false 7 | allowed-import-paths=["./data/storage"] 8 | enable-debug-timer = true 9 | 10 | [web] 11 | port = 10013 12 | frontend = "frontend" 13 | -------------------------------------------------------------------------------- /heavydb/heavydb_part4.conf: -------------------------------------------------------------------------------- 1 | port = 10020 2 | http-port = 10021 3 | calcite-port = 10022 4 | data = "./heavydb/heavydb_src/build/data-part4" 5 | read-only = false 6 | verbose = false 7 | allowed-import-paths=["./data/storage"] 8 | enable-debug-timer = true 9 | 10 | [web] 11 | port = 10023 12 | frontend = "frontend" 13 | -------------------------------------------------------------------------------- /heavydb/heavydb_part5.conf: -------------------------------------------------------------------------------- 1 | port = 10030 2 | http-port = 10031 3 | calcite-port = 10032 4 | data = "./heavydb/heavydb_src/build/data-part5" 5 | read-only = false 6 | verbose = false 7 | allowed-import-paths=["./data/storage"] 8 | enable-debug-timer = true 9 | 10 | [web] 11 | port = 10033 12 | frontend = "frontend" 13 | -------------------------------------------------------------------------------- /heavydb/heavydb_part6.conf: -------------------------------------------------------------------------------- 1 | port = 10040 2 | http-port = 10041 3 | calcite-port = 10042 4 | data = "./heavydb/heavydb_src/build/data-part6" 5 | read-only = false 6 | verbose = false 7 | allowed-import-paths=["./data/storage"] 8 | enable-debug-timer = true 9 | 10 | [web] 11 | port = 10043 12 | frontend = "frontend" 13 | -------------------------------------------------------------------------------- /heavydb/install_heavydb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export HEAVYDB_ROOT="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" 4 | mkdir $HEAVYDB_ROOT/.local 5 | 6 | # install heavydb dependencies 7 | cd $HEAVYDB_ROOT/heavydb_src 8 | ./scripts/mapd-deps-ubuntu.sh 9 | 10 | # env 11 | cd .. 12 | source .local/mapd-deps.sh 13 | 14 | # install heavydb 15 | cd heavydb_src 16 | mkdir build 17 | cd build 18 | cmake .. 19 | make -j 20 | -------------------------------------------------------------------------------- /heavydb/prepare_data_dir.sh: -------------------------------------------------------------------------------- 1 | # create data directory 2 | mkdir heavydb/heavydb_src/build/data-part3 3 | mkdir heavydb/heavydb_src/build/data-part4 4 | mkdir heavydb/heavydb_src/build/data-part5 5 | mkdir heavydb/heavydb_src/build/data-part6 6 | 7 | # init data directory 8 | ./heavydb/heavydb_src/build/bin/initheavy heavydb/heavydb_src/build/data-part3 9 | ./heavydb/heavydb_src/build/bin/initheavy heavydb/heavydb_src/build/data-part4 10 | ./heavydb/heavydb_src/build/bin/initheavy heavydb/heavydb_src/build/data-part5 11 | ./heavydb/heavydb_src/build/bin/initheavy heavydb/heavydb_src/build/data-part6 12 | 13 | # copy config files to heavydb directory 14 | cp heavydb_part3.conf ./heavydb 15 | cp heavydb_part4.conf ./heavydb 16 | cp heavydb_part5.conf ./heavydb 17 | cp heavydb_part6.conf ./heavydb -------------------------------------------------------------------------------- /heavydb/readme.md: -------------------------------------------------------------------------------- 1 | # Installation Instruction 2 | 3 | Clone heavydb code as `heavydb_src` in this folder and then run `install_heavydb.sh` script. -------------------------------------------------------------------------------- /heavydb/sql/aggregate_1gb_cached.sql: -------------------------------------------------------------------------------- 1 | select sum(aggregate_1.attr) 2 | from aggregate_1 3 | group by aggregate_1.pk; -------------------------------------------------------------------------------- /heavydb/sql/aggregate_1gb_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table aggregate_1; 2 | create table aggregate_1 (pk INT, attr INT); 3 | copy aggregate_1 4 | from './data/storage/aggregate_268435456_10000.parquet' with (parquet = 'true'); 5 | select sum(aggregate_1.attr) 6 | from aggregate_1 7 | group by aggregate_1.pk; -------------------------------------------------------------------------------- /heavydb/sql/join_100mb_1gb_cached.sql: -------------------------------------------------------------------------------- 1 | select * 2 | from join_1, 3 | join_2 4 | where join_1.pk = join_2.pk; -------------------------------------------------------------------------------- /heavydb/sql/join_100mb_1gb_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table join_1; 2 | drop table join_2; 3 | create table join_1 (pk INT, attr INT); 4 | create table join_2 (pk INT, attr INT); 5 | copy join_1 6 | from './data/storage/join_dim_26214400.parquet' with (parquet = 'true'); 7 | copy join_2 8 | from './data/storage/join_fact_268435456.parquet' with (parquet = 'true'); 9 | select * 10 | from join_1, 11 | join_2 12 | where join_1.pk = join_2.pk; -------------------------------------------------------------------------------- /heavydb/sql/join_1gb_1gb_cached.sql: -------------------------------------------------------------------------------- 1 | select * 2 | from join_1, 3 | join_2 4 | where join_1.pk = join_2.pk; -------------------------------------------------------------------------------- /heavydb/sql/join_1gb_1gb_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table join_1; 2 | drop table join_2; 3 | create table join_1 (pk INT, attr INT); 4 | create table join_2 (pk INT, attr INT); 5 | copy join_1 6 | from './data/storage/join_dim_268435456.parquet' with (parquet = 'true'); 7 | copy join_2 8 | from './data/storage/join_fact_268435456.parquet' with (parquet = 'true'); 9 | select * 10 | from join_1, 11 | join_2 12 | where join_1.pk = join_2.pk; -------------------------------------------------------------------------------- /heavydb/sql/sample.sql: -------------------------------------------------------------------------------- 1 | drop table sample_1; 2 | drop table sample_2; 3 | create table sample_1 (pk INT, attr INT); 4 | create table sample_2 (pk INT, attr INT); 5 | copy sample_1 6 | from './data/storage/sample_1.parquet' with (parquet = 'true'); 7 | copy sample_2 8 | from './data/storage/sample_2.parquet' with (parquet = 'true'); 9 | select * 10 | from sample_1, 11 | sample_2 12 | where sample_1.pk = sample_2.pk; -------------------------------------------------------------------------------- /heavydb/sql/scan_100mb_cached.sql: -------------------------------------------------------------------------------- 1 | select * 2 | from scan_1; -------------------------------------------------------------------------------- /heavydb/sql/scan_100mb_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table scan_1; 2 | create table scan_1 (pk INT, attr INT); 3 | copy scan_1 4 | from './data/storage/join_dim_26214400.parquet' with (parquet = 'true'); 5 | select * 6 | from scan_1; -------------------------------------------------------------------------------- /heavydb/sql/scan_1gb_cached.sql: -------------------------------------------------------------------------------- 1 | select * 2 | from scan_1; -------------------------------------------------------------------------------- /heavydb/sql/scan_1gb_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table scan_1; 2 | create table scan_1 (pk INT, attr INT); 3 | copy scan_1 4 | from './data/storage/join_fact_268435456.parquet' with (parquet = "true"); 5 | select * 6 | from scan_1; -------------------------------------------------------------------------------- /heavydb/sql/ssb_1col.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select lo_orderdate 90 | from lineorder 91 | where lo_discount between 1 and 3; -------------------------------------------------------------------------------- /heavydb/sql/ssb_allcol.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select lo_orderdate 90 | from lineorder 91 | where lo_discount between 1 and 3 92 | and lo_quantity < 10000; -------------------------------------------------------------------------------- /heavydb/sql/ssb_create_table.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); -------------------------------------------------------------------------------- /heavydb/sql/ssb_load_table.sql: -------------------------------------------------------------------------------- 1 | copy customer 2 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 3 | copy ddate 4 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 5 | copy lineorder 6 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 7 | copy part 8 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 9 | copy supplier 10 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); -------------------------------------------------------------------------------- /heavydb/sql/ssb_q11_cached.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice * lo_discount) as revenue 2 | from lineorder, 3 | ddate 4 | where lo_orderdate = d_datekey 5 | and d_year = 1993 6 | and lo_discount between 1 and 3 7 | and lo_quantity < 25; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q11_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select sum(lo_extendedprice * lo_discount) as revenue 90 | from lineorder, 91 | ddate 92 | where lo_orderdate = d_datekey 93 | and d_year = 1993 94 | and lo_discount between 1 and 3 95 | and lo_quantity < 25; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q12_cached.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice * lo_discount) as revenue 2 | from lineorder, 3 | ddate 4 | where lo_orderdate = d_datekey 5 | and d_yearmonthnum = 199401 6 | and lo_discount between 4 and 6 7 | and lo_quantity between 26 and 35; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q12_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select sum(lo_extendedprice * lo_discount) as revenue 90 | from lineorder, 91 | ddate 92 | where lo_orderdate = d_datekey 93 | and d_yearmonthnum = 199401 94 | and lo_discount between 4 and 6 95 | and lo_quantity between 26 and 35; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q13_cached.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_extendedprice * lo_discount) as revenue 2 | from lineorder, 3 | ddate 4 | where lo_orderdate = d_datekey 5 | and d_weeknuminyear = 6 6 | and d_year = 1994 7 | and lo_discount between 5 and 7 8 | and lo_quantity between 26 and 35; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q13_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select sum(lo_extendedprice * lo_discount) as revenue 90 | from lineorder, 91 | ddate 92 | where lo_orderdate = d_datekey 93 | and d_weeknuminyear = 6 94 | and d_year = 1994 95 | and lo_discount between 5 and 7 96 | and lo_quantity between 26 and 35; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q21_cached.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue), 2 | d_year, 3 | p_brand1 4 | from lineorder, 5 | ddate, 6 | part, 7 | supplier 8 | where lo_orderdate = d_datekey 9 | and lo_partkey = p_partkey 10 | and lo_suppkey = s_suppkey 11 | and p_category = 'MFGR#12' 12 | and s_region = 'AMERICA' 13 | group by d_year, 14 | p_brand1 15 | order by d_year, 16 | p_brand1; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q21_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select sum(lo_revenue), 90 | d_year, 91 | p_brand1 92 | from lineorder, 93 | ddate, 94 | part, 95 | supplier 96 | where lo_orderdate = d_datekey 97 | and lo_partkey = p_partkey 98 | and lo_suppkey = s_suppkey 99 | and p_category = 'MFGR#12' 100 | and s_region = 'AMERICA' 101 | group by d_year, 102 | p_brand1 103 | order by d_year, 104 | p_brand1; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q22_cached.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue), 2 | d_year, 3 | p_brand1 4 | from lineorder, 5 | ddate, 6 | part, 7 | supplier 8 | where lo_orderdate = d_datekey 9 | and lo_partkey = p_partkey 10 | and lo_suppkey = s_suppkey 11 | and p_brand1 between 'MFGR#2221' and 'MFGR#2228' 12 | and s_region = 'ASIA' 13 | group by d_year, 14 | p_brand1 15 | order by d_year, 16 | p_brand1; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q22_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select sum(lo_revenue), 90 | d_year, 91 | p_brand1 92 | from lineorder, 93 | ddate, 94 | part, 95 | supplier 96 | where lo_orderdate = d_datekey 97 | and lo_partkey = p_partkey 98 | and lo_suppkey = s_suppkey 99 | and p_brand1 between 'MFGR#2221' and 'MFGR#2228' 100 | and s_region = 'ASIA' 101 | group by d_year, 102 | p_brand1 103 | order by d_year, 104 | p_brand1; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q23_cached.sql: -------------------------------------------------------------------------------- 1 | select sum(lo_revenue), 2 | d_year, 3 | p_brand1 4 | from lineorder, 5 | ddate, 6 | part, 7 | supplier 8 | where lo_orderdate = d_datekey 9 | and lo_partkey = p_partkey 10 | and lo_suppkey = s_suppkey 11 | and p_brand1 = 'MFGR#2221' 12 | and s_region = 'EUROPE' 13 | group by d_year, 14 | p_brand1 15 | order by d_year, 16 | p_brand1; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q23_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select sum(lo_revenue), 90 | d_year, 91 | p_brand1 92 | from lineorder, 93 | ddate, 94 | part, 95 | supplier 96 | where lo_orderdate = d_datekey 97 | and lo_partkey = p_partkey 98 | and lo_suppkey = s_suppkey 99 | and p_brand1 = 'MFGR#2221' 100 | and s_region = 'EUROPE' 101 | group by d_year, 102 | p_brand1 103 | order by d_year, 104 | p_brand1; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q31_cached.sql: -------------------------------------------------------------------------------- 1 | select c_nation, 2 | s_nation, 3 | d_year, 4 | sum(lo_revenue) as revenue 5 | from customer, 6 | lineorder, 7 | supplier, 8 | ddate 9 | where lo_custkey = c_custkey 10 | and lo_suppkey = s_suppkey 11 | and lo_orderdate = d_datekey 12 | and c_region = 'ASIA' 13 | and s_region = 'ASIA' 14 | and d_year >= 1992 15 | and d_year <= 1997 16 | group by c_nation, 17 | s_nation, 18 | d_year 19 | order by d_year asc, 20 | revenue desc; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q31_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select c_nation, 90 | s_nation, 91 | d_year, 92 | sum(lo_revenue) as revenue 93 | from customer, 94 | lineorder, 95 | supplier, 96 | ddate 97 | where lo_custkey = c_custkey 98 | and lo_suppkey = s_suppkey 99 | and lo_orderdate = d_datekey 100 | and c_region = 'ASIA' 101 | and s_region = 'ASIA' 102 | and d_year >= 1992 103 | and d_year <= 1997 104 | group by c_nation, 105 | s_nation, 106 | d_year 107 | order by d_year asc, 108 | revenue desc; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q32_cached.sql: -------------------------------------------------------------------------------- 1 | select c_city, 2 | s_city, 3 | d_year, 4 | sum(lo_revenue) as revenue 5 | from customer, 6 | lineorder, 7 | supplier, 8 | ddate 9 | where lo_custkey = c_custkey 10 | and lo_suppkey = s_suppkey 11 | and lo_orderdate = d_datekey 12 | and c_nation = 'UNITED STATES' 13 | and s_nation = 'UNITED STATES' 14 | and d_year >= 1992 15 | and d_year <= 1997 16 | group by c_city, 17 | s_city, 18 | d_year 19 | order by d_year asc, 20 | revenue desc; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q32_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select c_city, 90 | s_city, 91 | d_year, 92 | sum(lo_revenue) as revenue 93 | from customer, 94 | lineorder, 95 | supplier, 96 | ddate 97 | where lo_custkey = c_custkey 98 | and lo_suppkey = s_suppkey 99 | and lo_orderdate = d_datekey 100 | and c_nation = 'UNITED STATES' 101 | and s_nation = 'UNITED STATES' 102 | and d_year >= 1992 103 | and d_year <= 1997 104 | group by c_city, 105 | s_city, 106 | d_year 107 | order by d_year asc, 108 | revenue desc; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q33_cached.sql: -------------------------------------------------------------------------------- 1 | select c_city, 2 | s_city, 3 | d_year, 4 | sum(lo_revenue) as revenue 5 | from customer, 6 | lineorder, 7 | supplier, 8 | ddate 9 | where lo_custkey = c_custkey 10 | and lo_suppkey = s_suppkey 11 | and lo_orderdate = d_datekey 12 | and ( 13 | c_city = 'UNITED KI1' 14 | or c_city = 'UNITED KI5' 15 | ) 16 | and ( 17 | s_city = 'UNITED KI1' 18 | or s_city = 'UNITED KI5' 19 | ) 20 | and d_year >= 1992 21 | and d_year <= 1997 22 | group by c_city, 23 | s_city, 24 | d_year 25 | order by d_year asc, 26 | revenue desc; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q33_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select c_city, 90 | s_city, 91 | d_year, 92 | sum(lo_revenue) as revenue 93 | from customer, 94 | lineorder, 95 | supplier, 96 | ddate 97 | where lo_custkey = c_custkey 98 | and lo_suppkey = s_suppkey 99 | and lo_orderdate = d_datekey 100 | and ( 101 | c_city = 'UNITED KI1' 102 | or c_city = 'UNITED KI5' 103 | ) 104 | and ( 105 | s_city = 'UNITED KI1' 106 | or s_city = 'UNITED KI5' 107 | ) 108 | and d_year >= 1992 109 | and d_year <= 1997 110 | group by c_city, 111 | s_city, 112 | d_year 113 | order by d_year asc, 114 | revenue desc; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q34_cached.sql: -------------------------------------------------------------------------------- 1 | select c_city, 2 | s_city, 3 | d_year, 4 | sum(lo_revenue) as revenue 5 | from customer, 6 | lineorder, 7 | supplier, 8 | ddate 9 | where lo_custkey = c_custkey 10 | and lo_suppkey = s_suppkey 11 | and lo_orderdate = d_datekey 12 | and ( 13 | c_city = 'UNITED KI1' 14 | or c_city = 'UNITED KI5' 15 | ) 16 | and ( 17 | s_city = 'UNITED KI1' 18 | or s_city = 'UNITED KI5' 19 | ) 20 | and d_yearmonth = 'Dec1997' 21 | group by c_city, 22 | s_city, 23 | d_year 24 | order by d_year asc, 25 | revenue desc; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q34_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select c_city, 90 | s_city, 91 | d_year, 92 | sum(lo_revenue) as revenue 93 | from customer, 94 | lineorder, 95 | supplier, 96 | ddate 97 | where lo_custkey = c_custkey 98 | and lo_suppkey = s_suppkey 99 | and lo_orderdate = d_datekey 100 | and ( 101 | c_city = 'UNITED KI1' 102 | or c_city = 'UNITED KI5' 103 | ) 104 | and ( 105 | s_city = 'UNITED KI1' 106 | or s_city = 'UNITED KI5' 107 | ) 108 | and d_yearmonth = 'Dec1997' 109 | group by c_city, 110 | s_city, 111 | d_year 112 | order by d_year asc, 113 | revenue desc; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q41_cached.sql: -------------------------------------------------------------------------------- 1 | select d_year, 2 | c_nation, 3 | sum(lo_revenue - lo_supplycost) as profit 4 | from ddate, 5 | customer, 6 | supplier, 7 | part, 8 | lineorder 9 | where lo_custkey = c_custkey 10 | and lo_suppkey = s_suppkey 11 | and lo_partkey = p_partkey 12 | and lo_orderdate = d_datekey 13 | and c_region = 'AMERICA' 14 | and s_region = 'AMERICA' 15 | and ( 16 | p_mfgr = 'MFGR#1' 17 | or p_mfgr = 'MFGR#2' 18 | ) 19 | group by d_year, 20 | c_nation 21 | order by d_year, 22 | c_nation; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q41_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select d_year, 90 | c_nation, 91 | sum(lo_revenue - lo_supplycost) as profit 92 | from ddate, 93 | customer, 94 | supplier, 95 | part, 96 | lineorder 97 | where lo_custkey = c_custkey 98 | and lo_suppkey = s_suppkey 99 | and lo_partkey = p_partkey 100 | and lo_orderdate = d_datekey 101 | and c_region = 'AMERICA' 102 | and s_region = 'AMERICA' 103 | and ( 104 | p_mfgr = 'MFGR#1' 105 | or p_mfgr = 'MFGR#2' 106 | ) 107 | group by d_year, 108 | c_nation 109 | order by d_year, 110 | c_nation; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q42_cached.sql: -------------------------------------------------------------------------------- 1 | select d_year, 2 | s_nation, 3 | p_category, 4 | sum(lo_revenue - lo_supplycost) as profit 5 | from ddate, 6 | customer, 7 | supplier, 8 | part, 9 | lineorder 10 | where lo_custkey = c_custkey 11 | and lo_suppkey = s_suppkey 12 | and lo_partkey = p_partkey 13 | and lo_orderdate = d_datekey 14 | and c_region = 'AMERICA' 15 | and s_region = 'AMERICA' 16 | and ( 17 | d_year = 1997 18 | or d_year = 1998 19 | ) 20 | and ( 21 | p_mfgr = 'MFGR#1' 22 | or p_mfgr = 'MFGR#2' 23 | ) 24 | group by d_year, 25 | s_nation, 26 | p_category 27 | order by d_year, 28 | s_nation, 29 | p_category; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q42_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select d_year, 90 | s_nation, 91 | p_category, 92 | sum(lo_revenue - lo_supplycost) as profit 93 | from ddate, 94 | customer, 95 | supplier, 96 | part, 97 | lineorder 98 | where lo_custkey = c_custkey 99 | and lo_suppkey = s_suppkey 100 | and lo_partkey = p_partkey 101 | and lo_orderdate = d_datekey 102 | and c_region = 'AMERICA' 103 | and s_region = 'AMERICA' 104 | and ( 105 | d_year = 1997 106 | or d_year = 1998 107 | ) 108 | and ( 109 | p_mfgr = 'MFGR#1' 110 | or p_mfgr = 'MFGR#2' 111 | ) 112 | group by d_year, 113 | s_nation, 114 | p_category 115 | order by d_year, 116 | s_nation, 117 | p_category; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q43_cached.sql: -------------------------------------------------------------------------------- 1 | select d_year, 2 | s_city, 3 | p_brand1, 4 | sum(lo_revenue - lo_supplycost) as profit 5 | from ddate, 6 | customer, 7 | supplier, 8 | part, 9 | lineorder 10 | where lo_custkey = c_custkey 11 | and lo_suppkey = s_suppkey 12 | and lo_partkey = p_partkey 13 | and lo_orderdate = d_datekey 14 | and c_region = 'AMERICA' 15 | and s_nation = 'UNITED STATES' 16 | and ( 17 | d_year = 1997 18 | or d_year = 1998 19 | ) 20 | and p_category = 'MFGR#14' 21 | group by d_year, 22 | s_city, 23 | p_brand1 24 | order by d_year, 25 | s_city, 26 | p_brand1; -------------------------------------------------------------------------------- /heavydb/sql/ssb_q43_uncached.sql: -------------------------------------------------------------------------------- 1 | drop table customer; 2 | drop table ddate; 3 | drop table lineorder; 4 | drop table part; 5 | drop table supplier; 6 | create table lineorder ( 7 | lo_orderkey integer not null, 8 | lo_linenumber integer not null, 9 | lo_custkey integer not null, 10 | lo_partkey integer not null, 11 | lo_suppkey integer not null, 12 | lo_orderdate integer not null, 13 | lo_orderpriority text not null, 14 | lo_shippriority text not null, 15 | lo_quantity integer not null, 16 | lo_extendedprice integer not null, 17 | lo_ordtotalprice integer not null, 18 | lo_discount integer not null, 19 | lo_revenue integer not null, 20 | lo_supplycost integer not null, 21 | lo_tax integer not null, 22 | lo_commitdate integer not null, 23 | lo_shopmode text not null, 24 | dummy double 25 | ); 26 | create table part ( 27 | p_partkey integer not null, 28 | p_name text not null, 29 | p_mfgr text not null, 30 | p_category text not null, 31 | p_brand1 text not null, 32 | p_color text not null, 33 | p_type text not null, 34 | p_size integer not null, 35 | p_container text not null, 36 | dummy double 37 | ); 38 | create table supplier ( 39 | s_suppkey integer not null, 40 | s_name text not null, 41 | s_address text not null, 42 | s_city text not null, 43 | s_nation text not null, 44 | s_region text not null, 45 | s_phone text not null, 46 | dummy double 47 | ); 48 | create table customer ( 49 | c_custkey integer not null, 50 | c_name text not null, 51 | c_address text not null, 52 | c_city text not null, 53 | c_nation text not null, 54 | c_region text not null, 55 | c_phone text not null, 56 | c_mktsegment text not null, 57 | dummy double 58 | ); 59 | create table ddate ( 60 | d_datekey integer not null, 61 | d_date text not null, 62 | d_dayofweek text not null, 63 | d_month text not null, 64 | d_year integer not null, 65 | d_yearmonthnum integer not null, 66 | d_yearmonth text not null, 67 | d_daynuminweek integer not null, 68 | d_daynuminmonth integer not null, 69 | d_daynuminyear integer not null, 70 | d_monthnuminyear integer not null, 71 | d_weeknuminyear integer not null, 72 | d_sellingseasin text not null, 73 | d_lastdayinweekfl integer not null, 74 | d_lastdayinmonthfl integer not null, 75 | d_holidayfl integer not null, 76 | d_weekdayfl integer not null, 77 | dummy double 78 | ); 79 | copy customer 80 | from './data/storage/sf[sfph]_customer.parquet' with (parquet = 'true'); 81 | copy ddate 82 | from './data/storage/sf[sfph]_date.parquet' with (parquet = 'true'); 83 | copy lineorder 84 | from './data/storage/sf[sfph]_lineorder.parquet' with (parquet = 'true'); 85 | copy part 86 | from './data/storage/sf[sfph]_part.parquet' with (parquet = 'true'); 87 | copy supplier 88 | from './data/storage/sf[sfph]_supplier.parquet' with (parquet = 'true'); 89 | select d_year, 90 | s_city, 91 | p_brand1, 92 | sum(lo_revenue - lo_supplycost) as profit 93 | from ddate, 94 | customer, 95 | supplier, 96 | part, 97 | lineorder 98 | where lo_custkey = c_custkey 99 | and lo_suppkey = s_suppkey 100 | and lo_partkey = p_partkey 101 | and lo_orderdate = d_datekey 102 | and c_region = 'AMERICA' 103 | and s_nation = 'UNITED STATES' 104 | and ( 105 | d_year = 1997 106 | or d_year = 1998 107 | ) 108 | and p_category = 'MFGR#14' 109 | group by d_year, 110 | s_city, 111 | p_brand1 112 | order by d_year, 113 | s_city, 114 | p_brand1; -------------------------------------------------------------------------------- /stats/ncu_export.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | 5 | from report_parser.ncu_parser import NcuParser 6 | from utility.counter_config import * 7 | 8 | 9 | def print_res(kn, metric_to_label, parser): 10 | for per_res in parser.gen_res(kn, list(metric_to_label.keys())): 11 | print(metric_to_label[per_res[0]], end=",") 12 | print(per_res[1]) 13 | 14 | 15 | def main(): 16 | parser = argparse.ArgumentParser() 17 | parser.add_argument( 18 | "--path", required=True, type=str, help="Path to parse ncu report." 19 | ) 20 | args = parser.parse_args() 21 | 22 | ncu_par = NcuParser(path=args.path) 23 | 24 | kernel_list = ncu_par.get_kernel_list() 25 | 26 | for kn in kernel_list: 27 | print("-----------------------------------------------------") 28 | print("Kernel name:", kn) 29 | print("------------------------------------") 30 | print_res(kn, metric_sol(), ncu_par) 31 | print("------------------------------------") 32 | print_res(kn, metric_roofline(), ncu_par) 33 | print("------------------------------------") 34 | print_res(kn, metric_occupancy(), ncu_par) 35 | print("------------------------------------") 36 | print_res(kn, metric_compute(), ncu_par) 37 | print("------------------------------------") 38 | print_res(kn, metric_memory(), ncu_par) 39 | print("------------------------------------") 40 | print_res(kn, metric_launch(), ncu_par) 41 | print("------------------------------------") 42 | print_res(kn, metric_warp(), ncu_par) 43 | print("------------------------------------") 44 | print_res(kn, metric_detail_warp(), ncu_par) 45 | print("-----------------------------------------------------") 46 | print_res(kn, metric_inst(), ncu_par) 47 | print("-----------------------------------------------------") 48 | 49 | 50 | if __name__ == "__main__": 51 | main() 52 | -------------------------------------------------------------------------------- /utility/profiler_logger.py: -------------------------------------------------------------------------------- 1 | import os 2 | import logging 3 | 4 | 5 | class CustomFormatter(logging.Formatter): 6 | 7 | grey = "\x1b[38;20m" 8 | yellow = "\x1b[33;20m" 9 | red = "\x1b[31;20m" 10 | bold_red = "\x1b[31;1m" 11 | reset = "\x1b[0m" 12 | format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)" 13 | 14 | FORMATS = { 15 | logging.DEBUG: grey + format + reset, 16 | logging.INFO: grey + format + reset, 17 | logging.WARNING: yellow + format + reset, 18 | logging.ERROR: red + format + reset, 19 | logging.CRITICAL: bold_red + format + reset, 20 | } 21 | 22 | def format(self, record): 23 | log_fmt = self.FORMATS.get(record.levelno) 24 | formatter = logging.Formatter(log_fmt) 25 | return formatter.format(record) 26 | 27 | 28 | class Singleton(type): 29 | _instances = {} 30 | 31 | def __call__(cls, *args, **kwargs): 32 | if cls not in cls._instances: 33 | cls._instances[cls] = super(Singleton, cls).__call__( 34 | *args, **kwargs 35 | ) 36 | return cls._instances[cls] 37 | 38 | 39 | class Logger(metaclass=Singleton): 40 | def __init__(self): 41 | self._logger = logging.getLogger("profiler") 42 | self._logger.setLevel(logging.DEBUG) 43 | 44 | if not os.path.isdir("./.log"): 45 | os.mkdir("./.log") 46 | 47 | ch = logging.FileHandler("./.log/profiler.log", mode="a") 48 | ch.setLevel(logging.DEBUG) 49 | 50 | ch.setFormatter(CustomFormatter()) 51 | 52 | self._logger.addHandler(ch) 53 | 54 | def get_logger(self): 55 | return self._logger 56 | 57 | 58 | LOGGER = Logger().get_logger() 59 | --------------------------------------------------------------------------------