Skip to content

Commit c000211

Browse files
committed
get_optimizer_switches procedure added, load script works now my moving comments into own line
1 parent a187edd commit c000211

File tree

2 files changed

+158
-33
lines changed

2 files changed

+158
-33
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
DROP PROCEDURE IF EXISTS get_optimizer_switches;
2+
3+
DELIMITER $$
4+
5+
CREATE DEFINER='root'@'localhost' PROCEDURE get_optimizer_switches(
6+
)
7+
COMMENT '
8+
Description
9+
-----------
10+
11+
Shows MariaDB Optimizer Switches in tabular form.
12+
13+
Parameters
14+
-----------
15+
16+
none
17+
18+
Example
19+
-----------
20+
21+
SQL> CALL sys.get_optimizer_switches();
22+
+---------------------------------+-------+
23+
| switch_name | value |
24+
+---------------------------------+-------+
25+
| index_merge | on |
26+
| index_merge_union | on |
27+
| index_merge_sort_union | on |
28+
| index_merge_intersection | on |
29+
| index_merge_sort_intersection | off |
30+
| engine_condition_pushdown | off |
31+
| index_condition_pushdown | on |
32+
| derived_merge | on |
33+
| derived_with_keys | on |
34+
| firstmatch | on |
35+
| loosescan | on |
36+
| materialization | on |
37+
| in_to_exists | on |
38+
| semijoin | on |
39+
| partial_match_rowid_merge | on |
40+
| partial_match_table_scan | on |
41+
| subquery_cache | on |
42+
| mrr | off |
43+
| mrr_cost_based | off |
44+
| mrr_sort_keys | off |
45+
| outer_join_with_cache | on |
46+
| semijoin_with_cache | on |
47+
| join_cache_incremental | on |
48+
| join_cache_hashed | on |
49+
| join_cache_bka | on |
50+
| optimize_join_buffer_size | on |
51+
| table_elimination | on |
52+
| extended_keys | on |
53+
| exists_to_in | on |
54+
| orderby_uses_equalities | on |
55+
| condition_pushdown_for_derived | on |
56+
| split_materialized | on |
57+
| condition_pushdown_for_subquery | on |
58+
| rowid_filter | on |
59+
| condition_pushdown_from_having | on |
60+
+---------------------------------+-------+
61+
35 rows in set (0.153 sec)
62+
63+
Query OK, 35 rows affected (0.191 sec)
64+
'
65+
SQL SECURITY INVOKER
66+
NOT DETERMINISTIC
67+
READS SQL DATA
68+
BEGIN
69+
DECLARE v_i INT DEFAULT 1;
70+
DECLARE v_n INT DEFAULT 1;
71+
72+
CREATE TEMPORARY TABLE IF NOT EXISTS `optimizer_switch_tmp` (`switch_name` VARCHAR(64), `value` VARCHAR(3));
73+
74+
WHILE v_i < LENGTH(@@optimizer_switch) AND v_n != 0 DO
75+
SET v_n = LOCATE(',', SUBSTRING(@@optimizer_switch FROM v_i));
76+
IF v_n = 0 THEN
77+
SET v_n = LENGTH(@@optimizer_switch) - v_i+2;
78+
END IF;
79+
INSERT INTO optimizer_switch_tmp VALUES (
80+
SUBSTRING_INDEX(SUBSTRING(@@optimizer_switch FROM v_i FOR v_n-1), '=', 1),
81+
SUBSTRING_INDEX(SUBSTRING(@@optimizer_switch FROM v_i FOR v_n-1), '=', -1)
82+
);
83+
SET v_i = v_i + v_n;
84+
END WHILE;
85+
86+
SELECT * FROM optimizer_switch_tmp;
87+
DROP TEMPORARY TABLE optimizer_switch_tmp;
88+
END;
89+
$$
90+
91+
DELIMITER ;

sys_10.sql

Lines changed: 67 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,32 @@ SOURCE ./before_setup.sql
1818
SOURCE ./views/version.sql
1919

2020
SOURCE ./tables/sys_config.sql
21-
SOURCE ./tables/sys_config_data_10.sql -- ported
21+
-- ported
22+
SOURCE ./tables/sys_config_data_10.sql
2223

2324
SOURCE ./triggers/sys_config_insert_set_user.sql
2425
SOURCE ./triggers/sys_config_update_set_user.sql
2526

2627
SOURCE ./functions/extract_schema_from_file_name.sql
2728
SOURCE ./functions/extract_table_from_file_name.sql
2829
SOURCE ./functions/format_bytes.sql
29-
SOURCE ./functions/format_path.sql -- not possible to port b/c P_S is too old
30+
-- not possible to port b/c P_S is too old
31+
SOURCE ./functions/format_path.sql
3032
SOURCE ./functions/format_statement.sql
3133
SOURCE ./functions/format_time.sql
3234
SOURCE ./functions/list_add.sql
3335
SOURCE ./functions/list_drop.sql
34-
SOURCE ./functions/ps_is_account_enabled.sql -- not possible to port b/c P_S is too old
36+
-- not possible to port b/c P_S is too old
37+
SOURCE ./functions/ps_is_account_enabled.sql
3538
SOURCE ./functions/ps_is_consumer_enabled.sql
3639
SOURCE ./functions/ps_is_instrument_default_enabled.sql
3740
SOURCE ./functions/ps_is_instrument_default_timed.sql
3841
SOURCE ./functions/ps_is_thread_instrumented.sql
3942
SOURCE ./functions/ps_thread_id.sql
4043
SOURCE ./functions/ps_thread_account.sql
4144
SOURCE ./functions/ps_thread_stack.sql
42-
-- SOURCE ./functions/ps_thread_trx_info.sql -- to port! Error which I do not understand
45+
-- to port! Error which I do not understand
46+
-- SOURCE ./functions/ps_thread_trx_info.sql
4347
SOURCE ./functions/quote_identifier.sql
4448
SOURCE ./functions/sys_get_config.sql
4549
SOURCE ./functions/version_major.sql
@@ -57,12 +61,17 @@ SOURCE ./views/i_s/schema_auto_increment_columns.sql
5761
SOURCE ./views/i_s/x_schema_flattened_keys.sql
5862
SOURCE ./views/i_s/schema_redundant_indexes.sql
5963

60-
SOURCE ./views/p_s/ps_check_lost_instrumentation.sql -- not possible to port b/c P_S is too old
61-
SOURCE ./views/p_s/processlist.sql -- See also further down!
62-
SOURCE ./views/p_s/x_processlist.sql -- See also further down!
64+
-- not possible to port b/c P_S is too old
65+
SOURCE ./views/p_s/ps_check_lost_instrumentation.sql
66+
-- See also further down!
67+
SOURCE ./views/p_s/processlist.sql
68+
-- See also further down!
69+
SOURCE ./views/p_s/x_processlist.sql
6370

64-
SOURCE ./views/p_s/sessions.sql -- See also further down!
65-
SOURCE ./views/p_s/x_sessions.sql -- See also further down!
71+
-- See also further down!
72+
SOURCE ./views/p_s/sessions.sql
73+
-- See also further down!
74+
SOURCE ./views/p_s/x_sessions.sql
6675

6776
SOURCE ./views/p_s/latest_file_io.sql
6877
SOURCE ./views/p_s/x_latest_file_io.sql
@@ -77,16 +86,26 @@ SOURCE ./views/p_s/x_io_global_by_wait_by_bytes.sql
7786
SOURCE ./views/p_s/io_global_by_wait_by_latency.sql
7887
SOURCE ./views/p_s/x_io_global_by_wait_by_latency.sql
7988

80-
-- SOURCE ./views/p_s/memory_by_user_by_current_bytes.sql -- not possible to port b/c P_S is too old
81-
-- SOURCE ./views/p_s/x_memory_by_user_by_current_bytes.sql -- not possible to port b/c P_S is too old
82-
-- SOURCE ./views/p_s/memory_by_host_by_current_bytes.sql -- not possible to port b/c P_S is too old
83-
-- SOURCE ./views/p_s/x_memory_by_host_by_current_bytes.sql -- not possible to port b/c P_S is too old
84-
-- SOURCE ./views/p_s/memory_by_thread_by_current_bytes.sql -- not possible to port b/c P_S is too old
85-
-- SOURCE ./views/p_s/x_memory_by_thread_by_current_bytes.sql -- not possible to port b/c P_S is too old
86-
-- SOURCE ./views/p_s/memory_global_by_current_bytes.sql -- not possible to port b/c P_S is too old
87-
-- SOURCE ./views/p_s/x_memory_global_by_current_bytes.sql -- not possible to port b/c P_S is too old
88-
-- SOURCE ./views/p_s/memory_global_total.sql -- not possible to port b/c P_S is too old
89-
-- SOURCE ./views/p_s/x_memory_global_total.sql -- not possible to port b/c P_S is too old
89+
-- not possible to port b/c P_S is too old
90+
-- SOURCE ./views/p_s/memory_by_user_by_current_bytes.sql
91+
-- not possible to port b/c P_S is too old
92+
-- SOURCE ./views/p_s/x_memory_by_user_by_current_bytes.sql
93+
-- not possible to port b/c P_S is too old
94+
-- SOURCE ./views/p_s/memory_by_host_by_current_bytes.sql
95+
-- not possible to port b/c P_S is too old
96+
-- SOURCE ./views/p_s/x_memory_by_host_by_current_bytes.sql
97+
-- not possible to port b/c P_S is too old
98+
-- SOURCE ./views/p_s/memory_by_thread_by_current_bytes.sql
99+
-- not possible to port b/c P_S is too old
100+
-- SOURCE ./views/p_s/x_memory_by_thread_by_current_bytes.sql
101+
-- not possible to port b/c P_S is too old
102+
-- SOURCE ./views/p_s/memory_global_by_current_bytes.sql
103+
-- not possible to port b/c P_S is too old
104+
-- SOURCE ./views/p_s/x_memory_global_by_current_bytes.sql
105+
-- not possible to port b/c P_S is too old
106+
-- SOURCE ./views/p_s/memory_global_total.sql
107+
-- not possible to port b/c P_S is too old
108+
-- SOURCE ./views/p_s/x_memory_global_total.sql
90109

91110
SOURCE ./views/p_s/schema_index_statistics.sql
92111
SOURCE ./views/p_s/x_schema_index_statistics.sql
@@ -98,8 +117,10 @@ SOURCE ./views/p_s/x_schema_table_statistics_with_buffer.sql
98117
SOURCE ./views/p_s/schema_tables_with_full_table_scans.sql
99118
SOURCE ./views/p_s/x_schema_tables_with_full_table_scans.sql
100119
SOURCE ./views/p_s/schema_unused_indexes.sql
101-
-- SOURCE ./views/p_s/schema_table_lock_waits.sql -- not possible to port b/c P_S is too old
102-
-- SOURCE ./views/p_s/x_schema_table_lock_waits.sql -- not possible to port b/c P_S is too old
120+
-- not possible to port b/c P_S is too old
121+
-- SOURCE ./views/p_s/schema_table_lock_waits.sql
122+
-- not possible to port b/c P_S is too old
123+
-- SOURCE ./views/p_s/x_schema_table_lock_waits.sql
103124

104125
SOURCE ./views/p_s/statement_analysis.sql
105126
SOURCE ./views/p_s/x_statement_analysis.sql
@@ -126,8 +147,10 @@ SOURCE ./views/p_s/user_summary_by_statement_latency.sql
126147
SOURCE ./views/p_s/x_user_summary_by_statement_latency.sql
127148
SOURCE ./views/p_s/user_summary_by_stages.sql
128149
SOURCE ./views/p_s/x_user_summary_by_stages.sql
129-
SOURCE ./views/p_s/user_summary.sql -- to port! Error which I do not understand
130-
SOURCE ./views/p_s/x_user_summary.sql -- to port! Error which I do not understand
150+
-- to port! Error which I do not understand
151+
SOURCE ./views/p_s/user_summary.sql
152+
-- to port! Error which I do not understand
153+
SOURCE ./views/p_s/x_user_summary.sql
131154

132155
SOURCE ./views/p_s/host_summary_by_file_io_type.sql
133156
SOURCE ./views/p_s/x_host_summary_by_file_io_type.sql
@@ -139,8 +162,10 @@ SOURCE ./views/p_s/host_summary_by_statement_latency.sql
139162
SOURCE ./views/p_s/x_host_summary_by_statement_latency.sql
140163
SOURCE ./views/p_s/host_summary_by_stages.sql
141164
SOURCE ./views/p_s/x_host_summary_by_stages.sql
142-
SOURCE ./views/p_s/host_summary.sql -- to port! Error which I do not understand
143-
SOURCE ./views/p_s/x_host_summary.sql -- to port! Error which I do not understand
165+
-- to port! Error which I do not understand
166+
SOURCE ./views/p_s/host_summary.sql
167+
-- to port! Error which I do not understand
168+
SOURCE ./views/p_s/x_host_summary.sql
144169

145170
SOURCE ./views/p_s/wait_classes_global_by_avg_latency.sql
146171
SOURCE ./views/p_s/x_wait_classes_global_by_avg_latency.sql
@@ -153,14 +178,20 @@ SOURCE ./views/p_s/x_waits_by_host_by_latency.sql
153178
SOURCE ./views/p_s/waits_global_by_latency.sql
154179
SOURCE ./views/p_s/x_waits_global_by_latency.sql
155180

156-
SOURCE ./views/p_s/metrics_56.sql -- not possible to port b/c P_S is too old
181+
-- not possible to port b/c P_S is too old
182+
SOURCE ./views/p_s/metrics_56.sql
157183

158-
-- SOURCE ./views/p_s/processlist_57.sql -- to port! See furhter up!
159-
-- SOURCE ./views/p_s/x_processlist_57.sql -- to port! See furhter up!
184+
-- to port! See furhter up!
185+
-- SOURCE ./views/p_s/processlist_57.sql
186+
-- to port! See furhter up!
187+
-- SOURCE ./views/p_s/x_processlist_57.sql
160188

161-
-- SOURCE ./views/p_s/sessions.sql -- to port! See furhter up!
162-
-- SOURCE ./views/p_s/x_sessions.sql -- to port! See furhter up!
163-
-- SOURCE ./views/p_s/session_ssl_status.sql -- not possible to port b/c P_S is too old
189+
-- to port! See furhter up!
190+
-- SOURCE ./views/p_s/sessions.sql
191+
-- to port! See furhter up!
192+
-- SOURCE ./views/p_s/x_sessions.sql
193+
-- not possible to port b/c P_S is too old
194+
-- SOURCE ./views/p_s/session_ssl_status.sql
164195

165196
SOURCE ./procedures/create_synonym_db.sql
166197
SOURCE ./procedures/execute_prepared_stmt.sql
@@ -169,7 +200,8 @@ SOURCE ./procedures/diagnostics.sql
169200

170201
SOURCE ./procedures/ps_statement_avg_latency_histogram.sql
171202
SOURCE ./procedures/ps_trace_statement_digest.sql
172-
SOURCE ./procedures/ps_trace_thread.sql -- to port!
203+
-- to port!
204+
SOURCE ./procedures/ps_trace_thread.sql
173205

174206
SOURCE ./procedures/ps_setup_disable_background_threads.sql
175207
SOURCE ./procedures/ps_setup_disable_consumer.sql
@@ -183,7 +215,8 @@ SOURCE ./procedures/ps_setup_enable_thread.sql
183215

184216
SOURCE ./procedures/ps_setup_reload_saved.sql
185217
SOURCE ./procedures/ps_setup_reset_to_default_57_before.sql
186-
SOURCE ./procedures/ps_setup_reset_to_default.sql -- differrent, to port!
218+
-- differrent, to port!
219+
SOURCE ./procedures/ps_setup_reset_to_default.sql
187220
SOURCE ./procedures/ps_setup_reset_to_default_57_after.sql
188221
SOURCE ./procedures/ps_setup_save.sql
189222
SOURCE ./procedures/ps_setup_show_disabled.sql
@@ -196,5 +229,6 @@ SOURCE ./procedures/ps_truncate_all_tables.sql
196229

197230
SOURCE ./procedures/statement_performance_analyzer.sql
198231
SOURCE ./procedures/table_exists.sql
232+
SOURCE ./procedures/get_optimizer_switches.sql
199233

200234
SOURCE ./after_setup.sql

0 commit comments

Comments
 (0)