Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions internal/impl/oracledb/bench/Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: '3'

# Running order:
# - task oracledb:up
# - task oracledb:archivelog
# - task rman:setup
# - task sqlcl:create
# - task sqlcl:data:users

tasks:
oracledb:up:
cmds:
- docker run -d
--name oracledb
-p 1521:1521
-e ORACLE_PWD=YourPassword123
container-registry.oracle.com/database/express:latest
# - task: oracledb:archivelog
# - task: rman:setup

oracledb:down:
cmd: docker rm -fv oracledb

oracledb:logs:
cmd: docker logs -f oracledb

sqlcl:
cmd: sqlcl system/YourPassword123@localhost:1521/XE {{.EXTRA_ARGS}}

sqlcl:create:
cmd: task sqlcl EXTRA_ARGS="@create.sql"

sqlcl:data:users:
cmd: task sqlcl EXTRA_ARGS="@users.sql"

sqlcl:data:products:
cmd: task sqlcl EXTRA_ARGS="@products.sql"

sqlcl:data:cart:
cmd: task sqlcl EXTRA_ARGS="@cart.sql"

sqlcl:drop-cache:
cmd: echo "DROP TABLE RPCN.CDC_CHECKPOINT_CACHE;" | sqlcl system/YourPassword123@localhost:1521/XE

oracledb:archivelog:
desc: Enable ARCHIVELOG mode (required for LogMiner/CDC). Must be run after oracledb:up.
cmds:
- docker exec oracledb mkdir -p /opt/oracle/oradata/recovery_area
- docker exec -i oracledb sqlplus / as sysdba < archivelog_enable.sql

rman:setup:
desc: Configure RMAN archive log retention policy for local CDC development
cmd: docker exec -i oracledb rman target / < rman_setup.rman
11 changes: 11 additions & 0 deletions internal/impl/oracledb/bench/archivelog_enable.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SHUTDOWN ABORT;
STARTUP;
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
ALTER PLUGGABLE DATABASE ALL OPEN;
ALTER SYSTEM SET db_recovery_file_dest_size = 10G SCOPE=BOTH;
ALTER SYSTEM SET db_recovery_file_dest = '/opt/oracle/oradata/recovery_area' SCOPE=BOTH;
SELECT LOG_MODE FROM V$DATABASE;
EXIT;
40 changes: 40 additions & 0 deletions internal/impl/oracledb/bench/benchmark_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
http:
debug_endpoints: true

input:
oracledb_cdc:
connection_string: oracle://system:YourPassword123@localhost:1521/XE
stream_snapshot: false
snapshot_max_batch_size: 500
logminer:
scn_window_size: 85000
backoff_interval: 2s
mining_interval: 0s
include:
- TESTDB.USERS
- TESTDB.PRODUCTS
- TESTDB.CART
batching:
count: 30000
period: 1s



output:
processors:
- benchmark:
interval: 1s
count_bytes: true
file:
path: "./internal/impl/oracledb/bench/results.json"
codec: lines
# stdout: {}
# drop: {}

logger:
level: INFO

metrics:
prometheus:
add_process_metrics: true
add_go_metrics: true
67 changes: 67 additions & 0 deletions internal/impl/oracledb/bench/cart.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
-- Oracle Database Benchmark - Cart Data
-- Connection: oracle://system:YourPassword123@localhost:1521/XE
-- Prerequisites: Run create.sql first

-- Enable output for debugging
SET SERVEROUTPUT ON;

-- Switch to testdb schema
ALTER SESSION SET CURRENT_SCHEMA = testdb;
/

DECLARE
cart_total NUMBER := 10000000;
cart_batch_size NUMBER := 10000;
cart_current NUMBER := 0;
batch_end NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE('Inserting test data into testdb.cart (' || cart_total || ' rows)...');

-- Oracle transactions start automatically, no explicit BEGIN needed
WHILE cart_current < cart_total
LOOP
batch_end := cart_current + cart_batch_size;
IF batch_end > cart_total THEN
batch_end := cart_total;
END IF;

-- Insert batch using a CTE-style approach
INSERT INTO testdb.cart (name, email, info, date_of_birth, created_at, is_active, login_count, balance)
SELECT
'cart-' || n, -- name
'cart' || n || '@example.com', -- email
RPAD('This is about cart ' || n || '. ', 1000, 'X'), -- info (40 repetitions ~1KB)
SYSDATE - MOD(n, 10000), -- date_of_birth, spread over ~27 years
SYSTIMESTAMP, -- created_at
CASE WHEN MOD(n, 2) = 0 THEN 1 ELSE 0 END, -- is_active alternating 1/0
MOD(n, 100), -- login_count between 0-99
CAST(MOD(n, 1000) + MOD(n, 100) / 100.0 AS NUMBER(10,2)) -- balance
FROM (
SELECT ROWNUM + cart_current AS n
FROM dual
CONNECT BY LEVEL <= (batch_end - cart_current)
);

cart_current := batch_end;

-- Log progress after every batch
DBMS_OUTPUT.PUT_LINE('Progress: ' || cart_current || '/' || cart_total || ' rows inserted into testdb.cart');

-- Explicitly commit the current transaction
COMMIT;

-- Oracle automatically starts a new transaction after COMMIT
END LOOP;

DBMS_OUTPUT.PUT_LINE('Completed: ' || cart_current || ' rows inserted into testdb.cart');
END;
/

-- Verification
DECLARE
cart_count NUMBER;
BEGIN
SELECT COUNT(*) INTO cart_count FROM testdb.cart;
DBMS_OUTPUT.PUT_LINE('Verification - testdb.cart: ' || cart_count || ' rows');
END;
/
Loading