| 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 | //------------------------- CONTAINS ------------------------------------------ |
| 12 | DUCKDB_BENCHMARK(ContainsRegular, "[contains_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 { // 11.5% of TPC-H SF 1 |
| 18 | return "SELECT COUNT(*) FROM lineitem WHERE contains(l_comment, 'regular')" ; |
| 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 "Contains word 'regular' in the l_comment" ; |
| 28 | } |
| 29 | FINISH_BENCHMARK(ContainsRegular) |
| 30 | |
| 31 | DUCKDB_BENCHMARK(ContainsAccording, "[contains_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 COUNT(*) FROM lineitem WHERE contains(l_comment, 'according')" ; |
| 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 "Contains word 'according' in the l_comment" ; |
| 47 | } |
| 48 | FINISH_BENCHMARK(ContainsAccording) |
| 49 | |
| 50 | //-------------------------------- Contains LIKE --------------------------------------- |
| 51 | DUCKDB_BENCHMARK(ContainsRegularLIKE, "[contains_tpch]" ) |
| 52 | void Load(DuckDBBenchmarkState *state) override { |
| 53 | // load the data into the tpch schema |
| 54 | tpch::dbgen(SF, state->db); |
| 55 | } |
| 56 | string GetQuery() override { // ~19% of TPC-H SF 1 |
| 57 | return "SELECT COUNT(*) FROM lineitem WHERE l_comment LIKE '%regular%'" ; |
| 58 | } |
| 59 | string VerifyResult(QueryResult *result) override { |
| 60 | if (!result->success) { |
| 61 | return result->error; |
| 62 | } |
| 63 | return string(); |
| 64 | } |
| 65 | string BenchmarkInfo() override { |
| 66 | return "Like word 'regular' in the l_comment" ; |
| 67 | } |
| 68 | FINISH_BENCHMARK(ContainsRegularLIKE) |
| 69 | |
| 70 | DUCKDB_BENCHMARK(ContainsAccordingLIKE, "[contains_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 { // 25% of TPC-H SF 1 |
| 76 | return "SELECT COUNT(*) FROM lineitem WHERE l_comment LIKE '%according%'" ; |
| 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 "Like word 'according' in the l_comment" ; |
| 86 | } |
| 87 | FINISH_BENCHMARK(ContainsAccordingLIKE) |
| 88 | |