should be it
This commit is contained in:
102
external/duckdb/test/sql/pragma/profiling/test_attach_and_checkpoint_latency.test
vendored
Normal file
102
external/duckdb/test/sql/pragma/profiling/test_attach_and_checkpoint_latency.test
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
# name: test/sql/pragma/profiling/test_attach_and_checkpoint_latency.test
|
||||
# group: [profiling]
|
||||
|
||||
require json
|
||||
|
||||
require noforcestorage
|
||||
|
||||
require skip_reload
|
||||
|
||||
# Setup.
|
||||
|
||||
statement ok
|
||||
SET threads = 1;
|
||||
|
||||
statement ok
|
||||
SET wal_autocheckpoint = '1TB';
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_checkpoint_on_shutdown;
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profile_fs.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"WAITING_TO_ATTACH_LATENCY": "true", "ATTACH_LOAD_STORAGE_LATENCY": "true", "ATTACH_REPLAY_WAL_LATENCY": "true", "CHECKPOINT_LATENCY": "true"}';
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='ALL';
|
||||
|
||||
# Finished setup.
|
||||
|
||||
# CHECKPOINT_LATENCY.
|
||||
|
||||
statement ok
|
||||
ATTACH '__TEST_DIR__/profile_fs.db';
|
||||
|
||||
statement ok
|
||||
CREATE TABLE profile_fs.tbl AS SELECT range AS id FROM range(100_000);
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
CHECKPOINT profile_fs;
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profile_fs.json';
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN checkpoint_latency > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
|
||||
# WAITING_TO_ATTACH_LATENCY, ATTACH_LOAD_STORAGE_LATENCY and ATTACH_REPLAY_WAL_LATENCY.
|
||||
|
||||
statement ok
|
||||
CREATE TABLE profile_fs.other_tbl AS SELECT range AS id FROM range(100_000);
|
||||
|
||||
statement ok
|
||||
DETACH profile_fs;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
ATTACH '__TEST_DIR__/profile_fs.db';
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profile_fs.json';
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN waiting_to_attach_latency > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN attach_load_storage_latency > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN attach_replay_wal_latency > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
46
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_blocked_thread_time.test
vendored
Normal file
46
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_blocked_thread_time.test
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
# name: test/sql/pragma/profiling/test_custom_profiling_blocked_thread_time.test
|
||||
# description: Test BLOCKED_THREAD_TIME metric.
|
||||
# group: [profiling]
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
PRAGMA threads = 4;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE bigdata AS SELECT i AS col_a, i AS col_b FROM range(0, 10000) tbl(i);
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"BLOCKED_THREAD_TIME": "true"}';
|
||||
|
||||
statement ok
|
||||
SELECT (SELECT COUNT(*) FROM bigdata WHERE col_a = 1) + (SELECT COUNT(*) FROM bigdata WHERE col_b = 1);
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
query I
|
||||
SELECT unnest(res) FROM (
|
||||
SELECT current_setting('custom_profiling_settings') AS raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
) ORDER BY ALL
|
||||
----
|
||||
"BLOCKED_THREAD_TIME": "true"
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
query I
|
||||
SELECT COUNT(blocked_thread_time) FROM metrics_output;
|
||||
----
|
||||
1
|
||||
108
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_disable_metrics.test
vendored
Normal file
108
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_disable_metrics.test
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
# name: test/sql/pragma/profiling/test_custom_profiling_disable_metrics.test
|
||||
# description: Change CPU_TIME and other metrics.
|
||||
# group: [profiling]
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"CPU_TIME": "false", "EXTRA_INFO": "true", "OPERATOR_CARDINALITY": "true", "OPERATOR_TIMING": "true", "LATENCY": "true"}';
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
# Evaluate results.
|
||||
|
||||
query I rowsort
|
||||
SELECT unnest(res) FROM (
|
||||
SELECT current_setting('custom_profiling_settings') AS raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
) ORDER BY ALL;
|
||||
----
|
||||
"EXTRA_INFO": "true"
|
||||
"LATENCY": "true"
|
||||
"OPERATOR_CARDINALITY": "true"
|
||||
"OPERATOR_TIMING": "true"
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement error
|
||||
SELECT cpu_time FROM metrics_output;
|
||||
----
|
||||
<REGEX>:Binder Error.*Referenced column "cpu_time" not found in FROM clause!.*
|
||||
|
||||
statement ok
|
||||
SELECT extra_info, latency FROM metrics_output;
|
||||
|
||||
# Re-enable the CPU TIME.
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"CPU_TIME": "true", "EXTRA_INFO": "true", "CUMULATIVE_CARDINALITY": "true", "CUMULATIVE_ROWS_SCANNED": "true"}'
|
||||
|
||||
query I
|
||||
SELECT unnest(res) FROM (
|
||||
SELECT current_setting('custom_profiling_settings') AS raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
) ORDER BY ALL
|
||||
----
|
||||
"CPU_TIME": "true"
|
||||
"CUMULATIVE_CARDINALITY": "true"
|
||||
"CUMULATIVE_ROWS_SCANNED": "true"
|
||||
"EXTRA_INFO": "true"
|
||||
|
||||
# Re-enabled profiling.
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN cpu_time > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN cumulative_cardinality > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
|
||||
# Only collect ROWS_SCANNED for table queries.
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN cumulative_rows_scanned > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
false
|
||||
|
||||
28
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_errors.test
vendored
Normal file
28
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_errors.test
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# name: test/sql/pragma/profiling/test_custom_profiling_errors.test
|
||||
# description: Test different errors for custom_profiling_settings.
|
||||
# group: [profiling]
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement error
|
||||
PRAGMA custom_profiling_settings='}}}}}}'
|
||||
----
|
||||
<REGEX>:IO Error.*Could not parse the custom profiler settings file due to incorrect JSON: "}}}}}}".*
|
||||
|
||||
statement error
|
||||
PRAGMA custom_profiling_settings=BONJOUR
|
||||
----
|
||||
<REGEX>:IO Error.*Could not parse the custom profiler settings file due to incorrect JSON: "BONJOUR".*
|
||||
|
||||
statement error
|
||||
PRAGMA custom_profiling_settings=[NOT_A_JSON]
|
||||
----
|
||||
<REGEX>:Binder Error.*SET value cannot contain column names.*
|
||||
|
||||
statement error
|
||||
PRAGMA custom_profiling_settings='{"INVALID_SETTING": "true"}'
|
||||
----
|
||||
<REGEX>:IO Error.*Invalid custom profiler settings: "INVALID_SETTING".*
|
||||
62
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_memory_and_temp_dir.test_slow
vendored
Normal file
62
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_memory_and_temp_dir.test_slow
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# name: test/sql/pragma/profiling/test_custom_profiling_memory_and_temp_dir.test_slow
|
||||
# description: Test SYSTEM_PEAK_BUFFER_MEMORY and SYSTEM_PEAK_TEMP_DIR_SIZE metrics.
|
||||
# group: [profiling]
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
SET memory_limit = '0.7gb';
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE test AS SELECT hash(range) i FROM range(100_000_000);
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
# should both be non-zero, and sum up to ~1 GB
|
||||
query III
|
||||
SELECT
|
||||
system_peak_buffer_memory != 0,
|
||||
system_peak_temp_dir_size != 0,
|
||||
round((system_peak_buffer_memory + system_peak_temp_dir_size) / 1e9),
|
||||
FROM metrics_output;
|
||||
----
|
||||
true true 1.0
|
||||
|
||||
# disabling should omit them from output
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"SYSTEM_PEAK_BUFFER_MEMORY": "false", "SYSTEM_PEAK_TEMP_DIR_SIZE": "false"}';
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE test AS SELECT hash(range) i FROM range(100_000_000);
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement error
|
||||
SELECT system_peak_buffer_memory FROM metrics_output;
|
||||
----
|
||||
Binder Error
|
||||
|
||||
statement error
|
||||
SELECT system_peak_temp_dir_size FROM metrics_output;
|
||||
----
|
||||
Binder Error
|
||||
200
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_optimizer.test
vendored
Normal file
200
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_optimizer.test
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
# name: test/sql/pragma/profiling/test_custom_profiling_optimizer.test
|
||||
# description: Test custom optimizer profiling settings.
|
||||
# group: [profiling]
|
||||
|
||||
# This file is automatically generated by scripts/generate_metric_enums.py
|
||||
# Do not edit this file manually, your changes will be overwritten
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"ALL_OPTIMIZERS": "true"}';
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
query I
|
||||
SELECT * FROM (
|
||||
SELECT unnest(res) str FROM (
|
||||
SELECT current_setting('custom_profiling_settings') as raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
)
|
||||
) WHERE '"true"' NOT in str
|
||||
ORDER BY ALL
|
||||
----
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{}'
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
query I
|
||||
SELECT unnest(res) FROM (
|
||||
SELECT current_setting('custom_profiling_settings') AS raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
) ORDER BY ALL;
|
||||
----
|
||||
(empty)
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"OPTIMIZER_JOIN_ORDER": "true"}'
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
query I
|
||||
SELECT unnest(res) FROM (
|
||||
SELECT current_setting('custom_profiling_settings') AS raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
) ORDER BY ALL;
|
||||
----
|
||||
"OPTIMIZER_JOIN_ORDER": "true"
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN optimizer_join_order > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
|
||||
statement ok
|
||||
SET disabled_optimizers = 'JOIN_ORDER';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"OPTIMIZER_JOIN_ORDER": "true"}'
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
query I
|
||||
SELECT unnest(res) FROM (
|
||||
SELECT current_setting('custom_profiling_settings') AS raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
) ORDER BY ALL;
|
||||
----
|
||||
(empty)
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"CUMULATIVE_OPTIMIZER_TIMING": "true"}';
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN cumulative_optimizer_timing > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
|
||||
# All phase timings must be collected when using detailed profiling mode.
|
||||
|
||||
statement ok
|
||||
RESET custom_profiling_settings;
|
||||
|
||||
statement ok
|
||||
SET profiling_mode = 'detailed';
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
query I
|
||||
SELECT * FROM (
|
||||
SELECT unnest(res) str FROM (
|
||||
SELECT current_setting('custom_profiling_settings') AS raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
)
|
||||
)
|
||||
WHERE '"true"' NOT IN str
|
||||
ORDER BY ALL
|
||||
----
|
||||
|
||||
statement ok
|
||||
RESET custom_profiling_settings;
|
||||
|
||||
statement ok
|
||||
SET profiling_mode = 'standard';
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
query I
|
||||
SELECT unnest(res) FROM (
|
||||
SELECT current_setting('custom_profiling_settings') AS raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
) ORDER BY ALL;
|
||||
----
|
||||
"ATTACH_LOAD_STORAGE_LATENCY": "true"
|
||||
"ATTACH_REPLAY_WAL_LATENCY": "true"
|
||||
"BLOCKED_THREAD_TIME": "true"
|
||||
"CHECKPOINT_LATENCY": "true"
|
||||
"CPU_TIME": "true"
|
||||
"CUMULATIVE_CARDINALITY": "true"
|
||||
"CUMULATIVE_ROWS_SCANNED": "true"
|
||||
"EXTRA_INFO": "true"
|
||||
"LATENCY": "true"
|
||||
"OPERATOR_CARDINALITY": "true"
|
||||
"OPERATOR_NAME": "true"
|
||||
"OPERATOR_ROWS_SCANNED": "true"
|
||||
"OPERATOR_TIMING": "true"
|
||||
"OPERATOR_TYPE": "true"
|
||||
"QUERY_NAME": "true"
|
||||
"RESULT_SET_SIZE": "true"
|
||||
"ROWS_RETURNED": "true"
|
||||
"SYSTEM_PEAK_BUFFER_MEMORY": "true"
|
||||
"SYSTEM_PEAK_TEMP_DIR_SIZE": "true"
|
||||
"TOTAL_BYTES_READ": "true"
|
||||
"TOTAL_BYTES_WRITTEN": "true"
|
||||
"WAITING_TO_ATTACH_LATENCY": "true"
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
SELECT cpu_time, extra_info, rows_returned, latency FROM metrics_output;
|
||||
|
||||
68
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_planner.test_slow
vendored
Normal file
68
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_planner.test_slow
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
# name: test/sql/pragma/profiling/test_custom_profiling_planner.test_slow
|
||||
# description: Test profiling the physical planner.
|
||||
# group: [profiling]
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"PLANNER": "true", "PHYSICAL_PLANNER": "true"}';
|
||||
|
||||
loop i 0 8
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t${i}(a int);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t${i} VALUES (1);
|
||||
|
||||
endloop
|
||||
|
||||
statement ok
|
||||
SELECT t1.a FROM t1
|
||||
JOIN t2 ON t1.a = t2.a
|
||||
JOIN t3 ON t2.a = t3.a
|
||||
JOIN t4 ON t3.a = t4.a
|
||||
JOIN t5 ON t4.a = t5.a
|
||||
JOIN t6 ON t5.a = t6.a
|
||||
JOIN t7 ON t6.a = t7.a;
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
query I rowsort
|
||||
SELECT unnest(res) FROM (
|
||||
SELECT current_setting('custom_profiling_settings') AS raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
) ORDER BY ALL
|
||||
----
|
||||
"PHYSICAL_PLANNER": "true"
|
||||
"PLANNER": "true"
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN physical_planner > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN planner > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
43
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_result_set_size.test
vendored
Normal file
43
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_result_set_size.test
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# name: test/sql/pragma/profiling/test_custom_profiling_result_set_size.test
|
||||
# description: Test RESULT_SET_SIZE metric.
|
||||
# group: [profiling]
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"RESULT_SET_SIZE": "true", "OPERATOR_CARDINALITY": "true"}'
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
CREATE TYPE Result AS UNION (
|
||||
Ok BOOLEAN,
|
||||
Err BIGINT
|
||||
);
|
||||
|
||||
# Expected size: 144 = 9 (length of list) * 12 (size of a string)
|
||||
query I
|
||||
SELECT
|
||||
CASE
|
||||
WHEN result_set_size = 144 THEN TRUE::Result
|
||||
ELSE result_set_size::Result
|
||||
END AS result
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
71
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_rows_scanned.test
vendored
Normal file
71
external/duckdb/test/sql/pragma/profiling/test_custom_profiling_rows_scanned.test
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
# name: test/sql/pragma/profiling/test_custom_profiling_rows_scanned.test
|
||||
# description: Test ROWS_SCANNED metric.
|
||||
# group: [profiling]
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"OPERATOR_CARDINALITY": "true", "OPERATOR_ROWS_SCANNED": "true", "CUMULATIVE_CARDINALITY": "true", "CUMULATIVE_ROWS_SCANNED": "true"}';
|
||||
|
||||
statement ok
|
||||
CREATE TABLE integers(i INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO integers VALUES (1), (2), (3), (NULL);
|
||||
|
||||
statement ok
|
||||
SELECT * FROM integers i1, integers i2 WHERE i1.i = i2.i ORDER BY 1;
|
||||
|
||||
statement ok
|
||||
pragma disable_profiling;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
SELECT cumulative_cardinality, cumulative_rows_scanned FROM metrics_output;
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN cumulative_rows_scanned > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
|
||||
# Only output the cumulative metric.
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"CUMULATIVE_CARDINALITY": "true", "CUMULATIVE_ROWS_SCANNED": "true", "BLOCKED_THREAD_TIME": "true"}';
|
||||
|
||||
statement ok
|
||||
SELECT * FROM integers i1, integers i2 WHERE i1.i = i2.i ORDER BY 1;
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN cumulative_rows_scanned > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
60
external/duckdb/test/sql/pragma/profiling/test_default_profiling_settings.test
vendored
Normal file
60
external/duckdb/test/sql/pragma/profiling/test_default_profiling_settings.test
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# name: test/sql/pragma/profiling/test_default_profiling_settings.test
|
||||
# description: Test default profiling settings.
|
||||
# group: [profiling]
|
||||
|
||||
# This file is automatically generated by scripts/generate_metric_enums.py
|
||||
# Do not edit this file manually, your changes will be overwritten
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
query I
|
||||
SELECT unnest(res) FROM (
|
||||
SELECT current_setting('custom_profiling_settings') AS raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
) ORDER BY ALL;
|
||||
----
|
||||
"ATTACH_LOAD_STORAGE_LATENCY": "true"
|
||||
"ATTACH_REPLAY_WAL_LATENCY": "true"
|
||||
"BLOCKED_THREAD_TIME": "true"
|
||||
"CHECKPOINT_LATENCY": "true"
|
||||
"CPU_TIME": "true"
|
||||
"CUMULATIVE_CARDINALITY": "true"
|
||||
"CUMULATIVE_ROWS_SCANNED": "true"
|
||||
"EXTRA_INFO": "true"
|
||||
"LATENCY": "true"
|
||||
"OPERATOR_CARDINALITY": "true"
|
||||
"OPERATOR_NAME": "true"
|
||||
"OPERATOR_ROWS_SCANNED": "true"
|
||||
"OPERATOR_TIMING": "true"
|
||||
"OPERATOR_TYPE": "true"
|
||||
"QUERY_NAME": "true"
|
||||
"RESULT_SET_SIZE": "true"
|
||||
"ROWS_RETURNED": "true"
|
||||
"SYSTEM_PEAK_BUFFER_MEMORY": "true"
|
||||
"SYSTEM_PEAK_TEMP_DIR_SIZE": "true"
|
||||
"TOTAL_BYTES_READ": "true"
|
||||
"TOTAL_BYTES_WRITTEN": "true"
|
||||
"WAITING_TO_ATTACH_LATENCY": "true"
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
SELECT cpu_time, extra_info, rows_returned, latency FROM metrics_output;
|
||||
|
||||
62
external/duckdb/test/sql/pragma/profiling/test_empty_profiling_settings.test
vendored
Normal file
62
external/duckdb/test/sql/pragma/profiling/test_empty_profiling_settings.test
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# name: test/sql/pragma/profiling/test_empty_profiling_settings.test
|
||||
# description: Test empty profiling settings.
|
||||
# group: [profiling]
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{}'
|
||||
|
||||
statement ok
|
||||
SELECT unnest(['Maia', 'Thijs', 'Mark', 'Hannes', 'Tom', 'Max', 'Carlo', 'Sam', 'Tania']) AS names ORDER BY random();
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
# Evaluate results.
|
||||
|
||||
query I
|
||||
SELECT unnest(res) FROM (
|
||||
SELECT current_setting('custom_profiling_settings') AS raw_setting,
|
||||
raw_setting.trim('{}') AS setting,
|
||||
string_split(setting, ', ') AS res
|
||||
) ORDER BY ALL
|
||||
----
|
||||
(empty)
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profiling_output.json';
|
||||
|
||||
statement error
|
||||
SELECT cpu_time FROM metrics_output;
|
||||
----
|
||||
<REGEX>:Binder Error.*Referenced column "cpu_time" not found in FROM clause!.*
|
||||
|
||||
statement error
|
||||
SELECT extra_info FROM metrics_output;
|
||||
----
|
||||
<REGEX>:Binder Error.*Referenced column "extra_info" not found in FROM clause!.*
|
||||
|
||||
statement error
|
||||
SELECT operator_cardinality FROM metrics_output;
|
||||
----
|
||||
<REGEX>:Binder Error.*Referenced column "operator_cardinality" not found in FROM clause!.*
|
||||
|
||||
statement error
|
||||
SELECT operator_timing FROM metrics_output;
|
||||
----
|
||||
<REGEX>:Binder Error.*Referenced column "operator_timing" not found in FROM clause!.*
|
||||
|
||||
statement error
|
||||
SELECT cumulative_cardinality FROM metrics_output;
|
||||
----
|
||||
<REGEX>:Binder Error.*Referenced column "cumulative_cardinality" not found in FROM clause!.*
|
||||
15
external/duckdb/test/sql/pragma/profiling/test_no_reset_setting.test
vendored
Normal file
15
external/duckdb/test/sql/pragma/profiling/test_no_reset_setting.test
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# name: test/sql/pragma/profiling/test_no_reset_setting.test
|
||||
# description: Test that the profiling settings are not reset after setting profiling output.
|
||||
# group: [profiling]
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profile_file.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"TOTAL_BYTES_READ": "true", "TOTAL_BYTES_WRITTEN": "true"}';
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='ALL';
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
135
external/duckdb/test/sql/pragma/profiling/test_profiling_all.test
vendored
Normal file
135
external/duckdb/test/sql/pragma/profiling/test_profiling_all.test
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
# name: test/sql/pragma/profiling/test_profiling_all.test
|
||||
# description: Test profiling all operator types.
|
||||
# group: [profiling]
|
||||
|
||||
require json
|
||||
|
||||
require skip_reload
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profile_attach.json';
|
||||
|
||||
# Test ATTACH.
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='ALL';
|
||||
|
||||
statement ok
|
||||
ATTACH '__TEST_DIR__/profile_attach.db';
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='SELECT';
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profile_attach.json';
|
||||
|
||||
query II
|
||||
SELECT latency != 0, contains(query_name, 'ATTACH') FROM metrics_output;
|
||||
----
|
||||
true true
|
||||
|
||||
# Test CREATE TABLE.
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='ALL';
|
||||
|
||||
statement ok
|
||||
CREATE TABLE profile_attach.tbl AS SELECT range AS id FROM range(10000);
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='SELECT';
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profile_attach.json';
|
||||
|
||||
query II
|
||||
SELECT latency != 0, contains(query_name, 'CREATE TABLE') FROM metrics_output;
|
||||
----
|
||||
true true
|
||||
|
||||
# Test INSERT.
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='ALL';
|
||||
|
||||
statement ok
|
||||
INSERT INTO profile_attach.tbl SELECT range + 20000 FROM range(10000);
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='SELECT';
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profile_attach.json';
|
||||
|
||||
query II
|
||||
SELECT latency != 0, contains(query_name, 'INSERT INTO') FROM metrics_output;
|
||||
----
|
||||
true true
|
||||
|
||||
# Test CREATE INDEX.
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='ALL';
|
||||
|
||||
statement ok
|
||||
CREATE INDEX idx ON profile_attach.tbl(id);
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='SELECT';
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profile_attach.json';
|
||||
|
||||
query II
|
||||
SELECT latency != 0, contains(query_name, 'CREATE INDEX') FROM metrics_output;
|
||||
----
|
||||
true true
|
||||
|
||||
# Test DETACH.
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='ALL';
|
||||
|
||||
statement ok
|
||||
DETACH profile_attach;
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='SELECT';
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profile_attach.json';
|
||||
|
||||
query II
|
||||
SELECT latency != 0, contains(query_name, 'DETACH') FROM metrics_output;
|
||||
----
|
||||
true true
|
||||
91
external/duckdb/test/sql/pragma/profiling/test_profiling_fs.test
vendored
Normal file
91
external/duckdb/test/sql/pragma/profiling/test_profiling_fs.test
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
# name: test/sql/pragma/profiling/test_profiling_fs.test
|
||||
# description: Test profiling file system reads and writes.
|
||||
# group: [profiling]
|
||||
|
||||
require json
|
||||
|
||||
require noforcestorage
|
||||
|
||||
require skip_reload
|
||||
|
||||
# FIXME: Enable when more read paths have been added to profiling.
|
||||
require no_alternative_verify
|
||||
|
||||
statement ok
|
||||
SET threads = 1;
|
||||
|
||||
statement ok
|
||||
SET wal_autocheckpoint = '1TB';
|
||||
|
||||
statement ok
|
||||
ATTACH '__TEST_DIR__/profile_fs.db';
|
||||
|
||||
statement ok
|
||||
CREATE TABLE profile_fs.tbl AS SELECT range AS id FROM range(10000);
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profile_fs.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"TOTAL_BYTES_READ": "true", "TOTAL_BYTES_WRITTEN": "true"}';
|
||||
|
||||
statement ok
|
||||
SET profiling_coverage='ALL';
|
||||
|
||||
statement ok
|
||||
CHECKPOINT profile_fs;
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profile_fs.json';
|
||||
|
||||
statement ok
|
||||
SELECT total_bytes_written FROM metrics_output;
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN total_bytes_written > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
|
||||
statement ok
|
||||
CREATE INDEX idx ON profile_fs.tbl(id);
|
||||
|
||||
statement ok
|
||||
DETACH profile_fs;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_profiling = 'json';
|
||||
|
||||
statement ok
|
||||
PRAGMA profiling_output = '__TEST_DIR__/profile_fs.json';
|
||||
|
||||
statement ok
|
||||
PRAGMA custom_profiling_settings='{"TOTAL_BYTES_READ": "true", "TOTAL_BYTES_WRITTEN": "true"}';
|
||||
|
||||
statement ok
|
||||
ATTACH '__TEST_DIR__/profile_fs.db';
|
||||
|
||||
statement ok
|
||||
SELECT * FROM profile_fs.tbl;
|
||||
|
||||
statement ok
|
||||
PRAGMA disable_profiling;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE TABLE metrics_output AS SELECT * FROM '__TEST_DIR__/profile_fs.json';
|
||||
|
||||
query I
|
||||
SELECT
|
||||
CASE WHEN total_bytes_read > 0 THEN 'true'
|
||||
ELSE 'false' END
|
||||
FROM metrics_output;
|
||||
----
|
||||
true
|
||||
Reference in New Issue
Block a user