1#include "benchmark_runner.hpp"
2#include "compare_result.hpp"
3#include "dbgen.hpp"
4#include "duckdb_benchmark_macro.hpp"
5
6using namespace duckdb;
7using namespace std;
8
9#define SF 2
10
11//----------------------------- SUFFIX ----------------------------------------
12DUCKDB_BENCHMARK(SuffixLineitemShort, "[suffix_tpch]")
13void Load(DuckDBBenchmarkState *state) override {
14 // load the data into the tpch schema
15 tpch::dbgen(SF, state->db);
16}
17string GetQuery() override { // 25% of TPC-H SF 1
18 return "SELECT l_shipinstruct FROM lineitem WHERE suffix(l_shipinstruct, 'NONE')";
19}
20string VerifyResult(QueryResult *result) override {
21 if (!result->success) {
22 return result->error;
23 }
24 return string();
25}
26string BenchmarkInfo() override {
27 return "Short Suffix LineItem";
28}
29FINISH_BENCHMARK(SuffixLineitemShort)
30
31DUCKDB_BENCHMARK(SuffixLineitemMedium, "[suffix_tpch]")
32void Load(DuckDBBenchmarkState *state) override {
33 // load the data into the tpch schema
34 tpch::dbgen(SF, state->db);
35}
36string GetQuery() override { // 25% of TPC-H SF 1
37 return "SELECT l_shipinstruct FROM lineitem WHERE suffix(l_shipinstruct, 'CK RETURN')";
38}
39string VerifyResult(QueryResult *result) override {
40 if (!result->success) {
41 return result->error;
42 }
43 return string();
44}
45string BenchmarkInfo() override {
46 return "Medium Suffix LineItem";
47}
48FINISH_BENCHMARK(SuffixLineitemMedium)
49
50DUCKDB_BENCHMARK(SuffixLineitemLong, "[suffix_tpch]")
51void Load(DuckDBBenchmarkState *state) override {
52 // load the data into the tpch schema
53 tpch::dbgen(SF, state->db);
54}
55string GetQuery() override { // 25% of TPC-H SF 1
56 return "SELECT l_shipinstruct FROM lineitem WHERE suffix(l_shipinstruct, 'LIVER IN PERSON')";
57}
58string VerifyResult(QueryResult *result) override {
59 if (!result->success) {
60 return result->error;
61 }
62 return string();
63}
64string BenchmarkInfo() override {
65 return "Long Suffix LineItem";
66}
67FINISH_BENCHMARK(SuffixLineitemLong)
68
69//-------------------------------- LIKE ---------------------------------------
70DUCKDB_BENCHMARK(SuffixLineitemLikeShort, "[suffix_tpch]")
71void Load(DuckDBBenchmarkState *state) override {
72 // load the data into the tpch schema
73 tpch::dbgen(SF, state->db);
74}
75string GetQuery() override {
76 return "SELECT l_shipinstruct FROM lineitem WHERE l_shipinstruct LIKE '%NONE'";
77}
78string VerifyResult(QueryResult *result) override {
79 if (!result->success) {
80 return result->error;
81 }
82 return string();
83}
84string BenchmarkInfo() override {
85 return "Short Suffix LineItem LIKE";
86}
87FINISH_BENCHMARK(SuffixLineitemLikeShort)
88
89DUCKDB_BENCHMARK(SuffixLineitemLikeMedium, "[suffix_tpch]")
90void Load(DuckDBBenchmarkState *state) override {
91 // load the data into the tpch schema
92 tpch::dbgen(SF, state->db);
93}
94string GetQuery() override {
95 return "SELECT l_shipinstruct FROM lineitem WHERE l_shipinstruct LIKE '%CK RETURN'";
96}
97string VerifyResult(QueryResult *result) override {
98 if (!result->success) {
99 return result->error;
100 }
101 return string();
102}
103string BenchmarkInfo() override {
104 return "Medium Suffix LineItem LIKE";
105}
106FINISH_BENCHMARK(SuffixLineitemLikeMedium)
107
108DUCKDB_BENCHMARK(SuffixLineitemLikeLong, "[suffix_tpch]")
109void Load(DuckDBBenchmarkState *state) override {
110 // load the data into the tpch schema
111 tpch::dbgen(SF, state->db);
112}
113string GetQuery() override {
114 return "SELECT l_shipinstruct FROM lineitem WHERE l_shipinstruct LIKE '%LIVER IN PERSON'";
115}
116string VerifyResult(QueryResult *result) override {
117 if (!result->success) {
118 return result->error;
119 }
120 return string();
121}
122string BenchmarkInfo() override {
123 return "LongSuffix LineItem LIKE";
124}
125FINISH_BENCHMARK(SuffixLineitemLikeLong)
126