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