| 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 1 |
| 10 | |
| 11 | DUCKDB_BENCHMARK(AdaptiveStringReorderingAND, "[expression_reordering]" ) |
| 12 | void Load(DuckDBBenchmarkState *state) override { |
| 13 | // load the data into the tpch schema |
| 14 | tpch::dbgen(SF, state->db); |
| 15 | } |
| 16 | string GetQuery() override { |
| 17 | return "SELECT * FROM lineitem WHERE l_comment LIKE '%' AND l_comment LIKE '%s%' AND l_comment LIKE '%str%';" ; |
| 18 | } |
| 19 | string VerifyResult(QueryResult *result) override { |
| 20 | if (!result->success) { |
| 21 | return result->error; |
| 22 | } |
| 23 | return string(); |
| 24 | } |
| 25 | string BenchmarkInfo() override { |
| 26 | return "Execute adaptive reordering query ..." ; |
| 27 | } |
| 28 | FINISH_BENCHMARK(AdaptiveStringReorderingAND) |
| 29 | |
| 30 | DUCKDB_BENCHMARK(AdaptiveStringReorderingOR, "[expression_reordering]" ) |
| 31 | void Load(DuckDBBenchmarkState *state) override { |
| 32 | // load the data into the tpch schema |
| 33 | tpch::dbgen(SF, state->db); |
| 34 | } |
| 35 | string GetQuery() override { |
| 36 | return "SELECT * FROM lineitem WHERE l_comment LIKE '%' OR l_comment LIKE '%s%' OR l_comment LIKE '%str%';" ; |
| 37 | } |
| 38 | string VerifyResult(QueryResult *result) override { |
| 39 | if (!result->success) { |
| 40 | return result->error; |
| 41 | } |
| 42 | return string(); |
| 43 | } |
| 44 | string BenchmarkInfo() override { |
| 45 | return "Execute adaptive reordering query ..." ; |
| 46 | } |
| 47 | FINISH_BENCHMARK(AdaptiveStringReorderingOR) |
| 48 | |
| 49 | DUCKDB_BENCHMARK(AdaptiveNumericReorderingAND, "[expression_reordering]" ) |
| 50 | void Load(DuckDBBenchmarkState *state) override { |
| 51 | // load the data into the tpch schema |
| 52 | tpch::dbgen(SF, state->db); |
| 53 | } |
| 54 | string 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 | } |
| 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 "Execute adaptive reordering query ..." ; |
| 66 | } |
| 67 | FINISH_BENCHMARK(AdaptiveNumericReorderingAND) |
| 68 | |
| 69 | DUCKDB_BENCHMARK(AdaptiveNumericReorderingOR, "[expression_reordering]" ) |
| 70 | void Load(DuckDBBenchmarkState *state) override { |
| 71 | // load the data into the tpch schema |
| 72 | tpch::dbgen(SF, state->db); |
| 73 | } |
| 74 | string 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 | } |
| 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 "Execute adaptive reordering query ..." ; |
| 86 | } |
| 87 | FINISH_BENCHMARK(AdaptiveNumericReorderingOR) |
| 88 | |
| 89 | DUCKDB_BENCHMARK(AdaptiveMixedReorderingAND, "[expression_reordering]" ) |
| 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 * FROM lineitem WHERE l_returnflag = 'R' AND l_orderkey > 5000 AND l_shipdate > 5;" ; |
| 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 "Execute adaptive reordering query ..." ; |
| 105 | } |
| 106 | FINISH_BENCHMARK(AdaptiveMixedReorderingAND) |
| 107 | |
| 108 | DUCKDB_BENCHMARK(AdaptiveMixedReorderingOR, "[expression_reordering]" ) |
| 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 * FROM lineitem WHERE l_returnflag = 'R' OR l_orderkey > 5000 OR l_shipdate > 5;" ; |
| 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 "Execute adaptive reordering query ..." ; |
| 124 | } |
| 125 | FINISH_BENCHMARK(AdaptiveMixedReorderingOR) |
| 126 | |