1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-11-02 06:13:16 +03:00

test(rbo): initial test

This commit is contained in:
Leonid Fedorov
2025-09-01 14:22:48 +00:00
committed by drrtuy
parent 0554ab3dd0
commit 2e9900ea24
2 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
--source ../include/have_columnstore.inc
--source ../include/functions.inc
--source ../include/cross_engine.inc
--disable_warnings
DROP DATABASE IF EXISTS rbo_parallel_ces;
--enable_warnings
CREATE DATABASE rbo_parallel_ces;
USE rbo_parallel_ces;
# Turn on plan logging to capture CSEP strings
SELECT calsettrace(1);
# Test table in InnoDB (routed to ColumnStore via CES)
CREATE TABLE Ti (col1 INT, col2 INT, col3 INT) ENGINE=InnoDB;
# Populate with 100 rows
INSERT INTO Ti (col1, col2, col3)
SELECT seq, seq+1, seq+2 FROM (SELECT seq FROM seq_1_to_100) AS numbers;
# Generate statistics, limit histogram size
SET @@histogram_size=10;
ANALYZE TABLE Ti PERSISTENT FOR ALL;
# Index to make basic stats available
CREATE INDEX excellent_index ON Ti(col1);
# Enable RBO
SET @@columnstore_unstable_optimizer=ON;
SET @@optimizer_switch='derived_merge=off';
# First run with parallel factor 5
SET @@columnstore_ces_optimization_parallel_factor=5;
# Execute a query to build and store plans
SELECT SUM(col1) FROM Ti;
# Snapshot plans into variables for readability
SET @orig_plan := mcsgetplan('original');
SET @opt_plan := mcsgetplan('optimized');
SET @rbo_rules := mcsgetplan('rules');
# Validate plan contents using stored plans
# Count Union Units by looking for opening unit blocks after the marker '--- Union Unit ---'
SET @uu_tail := SUBSTRING_INDEX(@orig_plan, '--- Union Unit ---', -1);
SET @unit_open := CONCAT(CHAR(10),' {',CHAR(10));
SELECT (CHAR_LENGTH(@uu_tail) - CHAR_LENGTH(REPLACE(@uu_tail, @unit_open, '')))/CHAR_LENGTH(@unit_open) AS unions_original;
SET @uu_tail := SUBSTRING_INDEX(@opt_plan, '--- Union Unit ---', -1);
SELECT (CHAR_LENGTH(@uu_tail) - CHAR_LENGTH(REPLACE(@uu_tail, @unit_open, '')))/CHAR_LENGTH(@unit_open) AS unions_optimized_5;
# Ensure rule was applied
SELECT @rbo_rules LIKE '%parallel_ces%' AS rule_parallel_ces_applied;
# Increase factor to 15 but expect 10 unions due to histogram_size cap
SET @@columnstore_ces_optimization_parallel_factor=15;
# Re-execute to rebuild plan with new factor
SELECT SUM(col1) FROM Ti;
SET @opt_plan := mcsgetplan('optimized');
SET @uu_tail := SUBSTRING_INDEX(@opt_plan, '--- Union Unit ---', -1);
SELECT (CHAR_LENGTH(@uu_tail) - CHAR_LENGTH(REPLACE(@uu_tail, @unit_open, '')))/CHAR_LENGTH(@unit_open) AS unions_optimized_15;
# Cleanup
SELECT calsettrace(0);
DROP DATABASE rbo_parallel_ces;
--source ../include/drop_functions.inc

View File

@@ -0,0 +1,17 @@
# -------------------------------------------------------------- #
# Enable cross engine join
# Configure user and password in Columnstore.xml file
# -------------------------------------------------------------- #
--exec /usr/bin/mcsSetConfig CrossEngineSupport User 'cejuser'
--exec /usr/bin/mcsSetConfig CrossEngineSupport Password 'Vagrant1|0000001'
# -------------------------------------------------------------- #
# Create corresponding in the server
# -------------------------------------------------------------- #
--disable_warnings
CREATE USER IF NOT EXISTS'cejuser'@'localhost' IDENTIFIED BY 'Vagrant1|0000001';
--enable_warnings
GRANT ALL PRIVILEGES ON *.* TO 'cejuser'@'localhost';
FLUSH PRIVILEGES;