A Range Merge Join for PostgreSQL

The objective of this project is to provide an implementation of a range join in PostgreSQL based on the sort-merge paradigm. This project is based on the BSc thesis of Thomas Mannhart.

Examples

Joining available employees with events

Given a relation emps that records employees (name) working in a department (dept) for the period eperiod, and a relation events that records events (event) within a department dept taking place on a specific date (day). Find which employees are available for a specific event.

name dept eperiod
Anton Sales [01-01-2020, 31-03-2020]
Thomas Marketing [01-01-2020, 30-06-2020]
Michael Marketing [01-03-2020, 31-12-2020]
Hans Sales [01-01-2020, 31-12-2020]
Thomas Accounting [01-07-2020, 31-12-2020]
event dept day
Fair CH Marketing 05-03-2020
Presentation Sales 15-06-2020
Fair IT Marketing 03-08-2020
Balance Report Accounting 03-08-2020
Product launch Marketing 15-10-2020
name dept event day
Thomas Marketing Fair CH 05-03-2020
Michael Marketing Fair CH 05-03-2020
Michael Marketing Fair IT 03-08-2020
Michael Marketing Product launch 15-10-2020
Hans Sales Presentation 15-06-2020
Thomas Accounting Balance Report 03-08-2020

Joining student marks with grading ranges

Given a relation marks that records students (name), their student number (snumber) along with their achieved mark (mark), and a relation grades that records the grade (grade) to assign when achieving a mark between mmin mmax. Find for each student the grade to assign.

name snumber mark
Anton 1232 23.5
Thomas 4356 95
Michael 1125 72
Hans 3425 90
mmin mmax grade
0.0 18 1
18.5 36 2
36.5 54 3
54.5 72 4
72.5 90 5
90.5 100 6
name snumber grade
Anton 1232 2
Thomas 4356 6
Michael 1125 4
Hans 3425 5

Resources

The details can be found in the technical report.
The schematic changes to the Merge Join executor can be found here.

The patch for PostgreSQL can be found here. And the instructions how to install it here.

The link to the pgsql-hackers thread can be found here.