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 1
10
11DUCKDB_BENCHMARK(AdaptiveStringReorderingAND, "[expression_reordering]")
12void Load(DuckDBBenchmarkState *state) override {
13 // load the data into the tpch schema
14 tpch::dbgen(SF, state->db);
15}
16string GetQuery() override {
17 return "SELECT * FROM lineitem WHERE l_comment LIKE '%' AND l_comment LIKE '%s%' AND l_comment LIKE '%str%';";
18}
19string VerifyResult(QueryResult *result) override {
20 if (!result->success) {
21 return result->error;
22 }
23 return string();
24}
25string BenchmarkInfo() override {
26 return "Execute adaptive reordering query ...";
27}
28FINISH_BENCHMARK(AdaptiveStringReorderingAND)
29
30DUCKDB_BENCHMARK(AdaptiveStringReorderingOR, "[expression_reordering]")
31void Load(DuckDBBenchmarkState *state) override {
32 // load the data into the tpch schema
33 tpch::dbgen(SF, state->db);
34}
35string GetQuery() override {
36 return "SELECT * FROM lineitem WHERE l_comment LIKE '%' OR l_comment LIKE '%s%' OR l_comment LIKE '%str%';";
37}
38string VerifyResult(QueryResult *result) override {
39 if (!result->success) {
40 return result->error;
41 }
42 return string();
43}
44string BenchmarkInfo() override {
45 return "Execute adaptive reordering query ...";
46}
47FINISH_BENCHMARK(AdaptiveStringReorderingOR)
48
49DUCKDB_BENCHMARK(AdaptiveNumericReorderingAND, "[expression_reordering]")
50void Load(DuckDBBenchmarkState *state) override {
51 // load the data into the tpch schema
52 tpch::dbgen(SF, state->db);
53}
54string GetQuery() override {
55 return "SELECT * FROM lineitem WHERE l_quantity < 11 AND l_shipdate < 727272 AND l_receiptdate < 828282 AND l_tax "
56 "< 0.05;";
57}
58string VerifyResult(QueryResult *result) override {
59 if (!result->success) {
60 return result->error;
61 }
62 return string();
63}
64string BenchmarkInfo() override {
65 return "Execute adaptive reordering query ...";
66}
67FINISH_BENCHMARK(AdaptiveNumericReorderingAND)
68
69DUCKDB_BENCHMARK(AdaptiveNumericReorderingOR, "[expression_reordering]")
70void Load(DuckDBBenchmarkState *state) override {
71 // load the data into the tpch schema
72 tpch::dbgen(SF, state->db);
73}
74string GetQuery() override {
75 return "SELECT * FROM lineitem WHERE l_quantity < 11 OR l_shipdate < 727272 OR l_receiptdate < 828282 OR l_tax < "
76 "0.05;";
77}
78string VerifyResult(QueryResult *result) override {
79 if (!result->success) {
80 return result->error;
81 }
82 return string();
83}
84string BenchmarkInfo() override {
85 return "Execute adaptive reordering query ...";
86}
87FINISH_BENCHMARK(AdaptiveNumericReorderingOR)
88
89DUCKDB_BENCHMARK(AdaptiveMixedReorderingAND, "[expression_reordering]")
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 * FROM lineitem WHERE l_returnflag = 'R' AND l_orderkey > 5000 AND l_shipdate > 5;";
96}
97string VerifyResult(QueryResult *result) override {
98 if (!result->success) {
99 return result->error;
100 }
101 return string();
102}
103string BenchmarkInfo() override {
104 return "Execute adaptive reordering query ...";
105}
106FINISH_BENCHMARK(AdaptiveMixedReorderingAND)
107
108DUCKDB_BENCHMARK(AdaptiveMixedReorderingOR, "[expression_reordering]")
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 * FROM lineitem WHERE l_returnflag = 'R' OR l_orderkey > 5000 OR l_shipdate > 5;";
115}
116string VerifyResult(QueryResult *result) override {
117 if (!result->success) {
118 return result->error;
119 }
120 return string();
121}
122string BenchmarkInfo() override {
123 return "Execute adaptive reordering query ...";
124}
125FINISH_BENCHMARK(AdaptiveMixedReorderingOR)
126