1#include "benchmark_runner.hpp"
2#include "duckdb_benchmark_macro.hpp"
3#include "duckdb/main/appender.hpp"
4
5#include <random>
6
7using namespace duckdb;
8using namespace std;
9
10#define RANGEJOIN_COUNT 100000
11
12DUCKDB_BENCHMARK(RangeJoin, "[micro]")
13virtual void Load(DuckDBBenchmarkState *state) {
14 // fixed seed random numbers
15 std::uniform_int_distribution<> distribution(1, 10000);
16 std::mt19937 gen;
17 gen.seed(42);
18
19 state->conn.Query("CREATE TABLE integers(i INTEGER, j INTEGER);");
20 Appender appender(state->conn, "integers"); // insert the elements into the database
21 for (size_t i = 0; i < RANGEJOIN_COUNT; i++) {
22 appender.BeginRow();
23 appender.Append<int32_t>(distribution(gen));
24 appender.Append<int32_t>(distribution(gen));
25 appender.EndRow();
26 }
27}
28
29virtual string GetQuery() {
30 return "SELECT * FROM integers a, integers b WHERE (a.i / 1000) > b.j;";
31}
32
33virtual string VerifyResult(QueryResult *result) {
34 if (!result->success) {
35 return result->error;
36 }
37 return string();
38}
39
40virtual string BenchmarkInfo() {
41 return StringUtil::Format("Runs the following query: \"SELECT * FROM "
42 "integers a, integers b WHERE (a.i / 1000) > b.j;\""
43 " on %d rows",
44 RANGEJOIN_COUNT);
45}
46FINISH_BENCHMARK(RangeJoin)
47