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//------------------------- CONTAINS ------------------------------------------
12DUCKDB_BENCHMARK(ContainsRegular, "[contains_tpch]")
13void Load(DuckDBBenchmarkState *state) override {
14 // load the data into the tpch schema
15 tpch::dbgen(SF, state->db);
16}
17string GetQuery() override { // 11.5% of TPC-H SF 1
18 return "SELECT COUNT(*) FROM lineitem WHERE contains(l_comment, 'regular')";
19}
20string VerifyResult(QueryResult *result) override {
21 if (!result->success) {
22 return result->error;
23 }
24 return string();
25}
26string BenchmarkInfo() override {
27 return "Contains word 'regular' in the l_comment";
28}
29FINISH_BENCHMARK(ContainsRegular)
30
31DUCKDB_BENCHMARK(ContainsAccording, "[contains_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 COUNT(*) FROM lineitem WHERE contains(l_comment, 'according')";
38}
39string VerifyResult(QueryResult *result) override {
40 if (!result->success) {
41 return result->error;
42 }
43 return string();
44}
45string BenchmarkInfo() override {
46 return "Contains word 'according' in the l_comment";
47}
48FINISH_BENCHMARK(ContainsAccording)
49
50//-------------------------------- Contains LIKE ---------------------------------------
51DUCKDB_BENCHMARK(ContainsRegularLIKE, "[contains_tpch]")
52void Load(DuckDBBenchmarkState *state) override {
53 // load the data into the tpch schema
54 tpch::dbgen(SF, state->db);
55}
56string GetQuery() override { // ~19% of TPC-H SF 1
57 return "SELECT COUNT(*) FROM lineitem WHERE l_comment LIKE '%regular%'";
58}
59string VerifyResult(QueryResult *result) override {
60 if (!result->success) {
61 return result->error;
62 }
63 return string();
64}
65string BenchmarkInfo() override {
66 return "Like word 'regular' in the l_comment";
67}
68FINISH_BENCHMARK(ContainsRegularLIKE)
69
70DUCKDB_BENCHMARK(ContainsAccordingLIKE, "[contains_tpch]")
71void Load(DuckDBBenchmarkState *state) override {
72 // load the data into the tpch schema
73 tpch::dbgen(SF, state->db);
74}
75string GetQuery() override { // 25% of TPC-H SF 1
76 return "SELECT COUNT(*) FROM lineitem WHERE l_comment LIKE '%according%'";
77}
78string VerifyResult(QueryResult *result) override {
79 if (!result->success) {
80 return result->error;
81 }
82 return string();
83}
84string BenchmarkInfo() override {
85 return "Like word 'according' in the l_comment";
86}
87FINISH_BENCHMARK(ContainsAccordingLIKE)
88