Skip to content

Instantly share code, notes, and snippets.

postgresql - object-relational SQL database (supported version)
postgresql-16 - The World's Most Advanced Open Source Relational Database
postgresql-client - front-end programs for PostgreSQL (supported version)
postgresql-client-16 - front-end programs for PostgreSQL 16
postgresql-client-common - manager for multiple PostgreSQL client versions
postgresql-common - PostgreSQL database-cluster manager
postgresql-contrib - additional facilities for PostgreSQL (supported version)
postgresql-doc - documentation for the PostgreSQL database management system
postgresql-doc-16 - documentation for the PostgreSQL database management system
diff --git a/sql/opt_split.cc b/sql/opt_split.cc
index 96459a0679e..39f3909db7e 100644
--- a/sql/opt_split.cc
+++ b/sql/opt_split.cc
@@ -968,7 +968,7 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(uint idx,
/*
Check whether there are keys that can be used to join T employing splitting
and if so, select the best out of such keys
- */
+ */ fprintf(stderr, "JOIN_TAB(%s)::choose_best_splitting()\n", table->alias.ptr());
ANALYZE: {
"query_optimization": {
"r_total_time_ms": 0.416255647
},
"query_block": {
"select_id": 1,
"cost": 3572.482611,
"r_loops": 1,
"r_total_time_ms": 7871.640272,
"filesort": {
ANALYZE: {
"query_optimization": {
"r_total_time_ms": 0.424920516
},
"query_block": {
"select_id": 1,
"cost": 2809.527303,
"r_loops": 1,
"r_total_time_ms": 7881.497717,
"filesort": {
MariaDB [test]> analyze format=json select * from t1 left join t3 on t3.a=t1.a and t3.b in (1,2,3,4) left join t2 on t2.a=t1.a and t2.b in (1,2,3,4)\G
*************************** 1. row ***************************
ANALYZE: {
"query_optimization": {
"r_total_time_ms": 0.065708193
},
"query_block": {
"select_id": 1,
"cost": 9010.04191,
MariaDB [test]> analyze format=json select * from t1 left join t2 on t2.a=t1.a and t2.b in (1,2,3,4) left join t3 on t3.a=t1.a and t3.b in (1,2,3,4);
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
create table t10 (a int, b int, index(a), index(b)) engine=innodb;
insert into t10 select seq, seq from seq_1_to_10000;
analyze table t10;
Table Op Msg_type Msg_text
test.t10 analyze status Engine-independent statistics collected
test.t10 analyze status OK
set optimizer_record_context=ON;
set optimizer_trace=1;
explain format=json select * from t10 A, t10 B where A.a< 3 and B.a < 333;
EXPLAIN
--source include/not_embedded.inc
--source include/have_sequence.inc
--source include/have_innodb.inc
# TODO: const tables are not supported at the moment, so use InnoDB.
create table t10 (a int, b int, index(a), index(b)) engine=innodb;
insert into t10 select seq, seq from seq_1_to_10000;
analyze table t10;
MariaDB [j3]> create table t5nopart(pk int primary key, kp1 int, kp2 int, filler int, key(kp1, kp2));
Query OK, 0 rows affected (0.028 sec)
MariaDB [j3]> insert into t5nopart select seq, seq/40, seq, seq from seq_1_to_4000;
Query OK, 4000 rows affected (0.312 sec)
Records: 4000 Duplicates: 0 Warnings: 0
MariaDB [j3]> explain
-> select * from t5nopart where kp1=10 and mod(kp2,2)=1 and kp2+1<401;
diff --git a/sql/opt_group_by_cardinality.cc b/sql/opt_group_by_cardinality.cc
index fd8367e41a7..dff716991a9 100644
--- a/sql/opt_group_by_cardinality.cc
+++ b/sql/opt_group_by_cardinality.cc
@@ -396,6 +396,8 @@ bool find_table_in_select( SQL_I_List<TABLE_LIST> *tl, TABLE *needle )
/*
Set bit in bitmap corresponding to a key that is the item in our select
+ TODO: that's difficult to understand. It's better if this function
+ just returned the key part number.