|
| 1 | +# Benchmark configuration for GAP_FILL in EOWC (Emit On Window Close) mode |
| 2 | +# This benchmark measures the throughput of processing incoming data through GAP_FILL with EOWC |
| 3 | +benchmark_name: gap_fill_eowc |
| 4 | + |
| 5 | +# SQL to set up the initial schema and data (run once) |
| 6 | +setup_sql: | |
| 7 | + CREATE TABLE sensor_data_eowc ( |
| 8 | + ts TIMESTAMP, |
| 9 | + value DOUBLE, |
| 10 | + WATERMARK FOR ts AS ts - INTERVAL '1' MINUTE, |
| 11 | + PRIMARY KEY (ts) |
| 12 | + ) APPEND ONLY; |
| 13 | +
|
| 14 | + CREATE MATERIALIZED VIEW gap_filled_sensors_eowc AS |
| 15 | + SELECT ts, value |
| 16 | + FROM GAP_FILL(sensor_data_eowc, ts, INTERVAL '1' MINUTE) |
| 17 | + EMIT ON WINDOW CLOSE; |
| 18 | +
|
| 19 | +# SQL to prepare the data before each run |
| 20 | +prepare_sql: | |
| 21 | + -- No preparation needed for each run |
| 22 | +
|
| 23 | +# SQL to clean up after each run |
| 24 | +conclude_sql: | |
| 25 | + -- APPEND ONLY tables do not support DELETE |
| 26 | + -- We use different time ranges for each run to avoid primary key conflicts |
| 27 | +
|
| 28 | +# SQL to clean up everything after all runs are complete |
| 29 | +cleanup_sql: | |
| 30 | + DROP MATERIALIZED VIEW IF EXISTS gap_filled_sensors_eowc; |
| 31 | + DROP TABLE IF EXISTS sensor_data_eowc; |
| 32 | +
|
| 33 | +# SQL to benchmark - Insert sparse time series data and measure processing time |
| 34 | +# This tests the throughput of GAP_FILL with EOWC processing incoming data |
| 35 | +# Note: Uses current timestamp to ensure unique time ranges for each run |
| 36 | +benchmark_sql: | |
| 37 | + -- Insert data with gaps (every 5 minutes) starting from NOW() |
| 38 | + -- Each run will use a different time range since NOW() advances |
| 39 | + INSERT INTO sensor_data_eowc (ts, value) |
| 40 | + SELECT |
| 41 | + NOW() + (i * INTERVAL '5 minutes'), |
| 42 | + 20.0 + (i * 0.5) |
| 43 | + FROM generate_series(0, 100) AS i; |
| 44 | +
|
| 45 | + -- Insert a timestamp far in the future to advance watermark and close all windows |
| 46 | + -- Watermark is defined as ts - INTERVAL '1' MINUTE, so this will close all windows |
| 47 | + INSERT INTO sensor_data_eowc (ts, value) |
| 48 | + VALUES ( |
| 49 | + NOW() + INTERVAL '10 hours', -- Far enough to close all windows |
| 50 | + 999.0 |
| 51 | + ); |
| 52 | +
|
| 53 | + -- Wait for watermark to advance and windows to close |
| 54 | + SELECT pg_sleep(3); |
| 55 | +
|
| 56 | + -- Query the results - windows should now be closed by watermark advancement |
| 57 | + SELECT COUNT(*) FROM gap_filled_sensors_eowc; |
| 58 | +
|
| 59 | +# Number of times to run the benchmark |
| 60 | +runs: 30 |
| 61 | + |
0 commit comments