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//----------------------------- PREFIX ----------------------------------------
12DUCKDB_BENCHMARK(PrefixLineitem, "[prefix_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 prefix(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 "Prefix early out LineItem";
28}
29FINISH_BENCHMARK(PrefixLineitem)
30
31DUCKDB_BENCHMARK(PrefixLineitemInlined, "[prefix_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 prefix(l_shipinstruct, 'COLLECT')";
38}
39string VerifyResult(QueryResult *result) override {
40 if (!result->success) {
41 return result->error;
42 }
43 return string();
44}
45string BenchmarkInfo() override {
46 return "Prefix inlined LineItem";
47}
48FINISH_BENCHMARK(PrefixLineitemInlined)
49
50DUCKDB_BENCHMARK(PrefixLineitemPointer, "[prefix_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 prefix(l_shipinstruct, 'DELIVER IN PERS')";
57}
58string VerifyResult(QueryResult *result) override {
59 if (!result->success) {
60 return result->error;
61 }
62 return string();
63}
64string BenchmarkInfo() override {
65 return "Prefix inlined LineItem";
66}
67FINISH_BENCHMARK(PrefixLineitemPointer)
68
69//-------------------------------- LIKE ---------------------------------------
70DUCKDB_BENCHMARK(PrefixLineitemLike, "[prefix_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 "Prefix early out LineItem LIKE";
86}
87FINISH_BENCHMARK(PrefixLineitemLike)
88
89DUCKDB_BENCHMARK(PrefixLineitemInlinedLike, "[prefix_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 'COLLECT%'";
96}
97string VerifyResult(QueryResult *result) override {
98 if (!result->success) {
99 return result->error;
100 }
101 return string();
102}
103string BenchmarkInfo() override {
104 return "Prefix inlined LineItem LIKE";
105}
106FINISH_BENCHMARK(PrefixLineitemInlinedLike)
107
108DUCKDB_BENCHMARK(PrefixLineitemPointerLike, "[prefix_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 'DELIVER IN PERS%'";
115}
116string VerifyResult(QueryResult *result) override {
117 if (!result->success) {
118 return result->error;
119 }
120 return string();
121}
122string BenchmarkInfo() override {
123 return "Prefix inlined LineItem LIKE";
124}
125FINISH_BENCHMARK(PrefixLineitemPointerLike)
126