4262 Jonas Oreland 2011-08-29 [merge]
ndb - merge 70 to 71
modified:
mysql-test/suite/ndb/r/ndb_index_stat.result
mysql-test/suite/ndb/r/ndb_statistics1.result
mysql-test/suite/ndb/t/ndb_index_stat.test
sql/ha_ndbcluster.cc
4261 jonas oreland 2011-08-27 [merge]
ndb - merge 70 to 71
added:
storage/ndb/src/kernel/vm/mt_thr_config.cpp
storage/ndb/src/kernel/vm/mt_thr_config.hpp
modified:
sql/ha_ndbcluster_binlog.cc
sql/ha_ndbinfo.cc
storage/ndb/include/util/SparseBitmask.hpp
storage/ndb/src/kernel/SimBlockList.cpp
storage/ndb/src/kernel/vm/Configuration.cpp
storage/ndb/src/kernel/vm/Configuration.hpp
storage/ndb/src/kernel/vm/Makefile.am
storage/ndb/src/kernel/vm/SimulatedBlock.cpp
storage/ndb/src/kernel/vm/SimulatedBlock.hpp
storage/ndb/src/kernel/vm/dummy_nonmt.cpp
storage/ndb/src/kernel/vm/mt.cpp
storage/ndb/src/kernel/vm/mt.hpp
=== modified file 'mysql-test/suite/ndb/r/ndb_index_stat.result'
--- a/mysql-test/suite/ndb/r/ndb_index_stat.result 2011-07-23 14:38:08 +0000
+++ b/mysql-test/suite/ndb/r/ndb_index_stat.result 2011-08-28 13:29:22 +0000
@@ -475,6 +475,18 @@ select count(*) from t1 where f > '222';
count(*)
1
drop table t1;
+create table t1 (a1 int, b1 int, primary key(b1), key(a1)) engine=ndbcluster partition by key() partitions 1;
+create table t2 (b2 int, c2 int, primary key(b2,c2)) engine=ndbcluster partition by key() partitions 1;
+# table t1 is only for forcing record by key count for table t2 that should be near 50 (not 1)
+analyze table t1, t2;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+test.t2 analyze status OK
+explain select * from t1, t2 where b2 = b1 and a1 = 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref PRIMARY,a1 a1 5 const 2 #
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.b1 50 #
+drop table t1, t2;
set @is_enable = @is_enable_default;
set @is_enable = NULL;
# is_enable_on=0 is_enable_off=1
=== modified file 'mysql-test/suite/ndb/r/ndb_statistics1.result'
--- a/mysql-test/suite/ndb/r/ndb_statistics1.result 2011-07-25 17:11:41 +0000
+++ b/mysql-test/suite/ndb/r/ndb_statistics1.result 2011-08-28 18:21:59 +0000
@@ -77,7 +77,7 @@ SELECT * FROM t10000 AS X JOIN t10000 AS
ON Y.I=X.I AND Y.J = X.I;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE X ALL I NULL NULL NULL 10000
-1 SIMPLE Y ref J,I I 10 test.X.I,test.X.I 1 Using where
+1 SIMPLE Y ref J,I J 5 test.X.I 1 Using where
EXPLAIN
SELECT * FROM t100 WHERE k < 42;
id select_type table type possible_keys key key_len ref rows Extra
@@ -145,11 +145,11 @@ id select_type table type possible_keys
EXPLAIN
SELECT * FROM t10000 WHERE J = 0 AND K < 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t10000 range PRIMARY,J PRIMARY 4 NULL 2 Using where with pushed condition
+1 SIMPLE t10000 ref PRIMARY,J J 5 const 2 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE J = 0 AND K BETWEEN 1 AND 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t10000 range PRIMARY,J PRIMARY 4 NULL 2 Using where with pushed condition
+1 SIMPLE t10000 ref PRIMARY,J J 5 const 2 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE J = 0 AND K = 1;
id select_type table type possible_keys key key_len ref rows Extra
=== modified file 'mysql-test/suite/ndb/t/ndb_index_stat.test'
--- a/mysql-test/suite/ndb/t/ndb_index_stat.test 2011-07-23 14:35:37 +0000
+++ b/mysql-test/suite/ndb/t/ndb_index_stat.test 2011-08-28 13:29:22 +0000
@@ -309,5 +309,30 @@ while ($i)
}
drop table t1;
+#
+# Check estimates of records per key for partial keys using unique/primary ordered index
+#
+
+create table t1 (a1 int, b1 int, primary key(b1), key(a1)) engine=ndbcluster partition by key() partitions 1;
+create table t2 (b2 int, c2 int, primary key(b2,c2)) engine=ndbcluster partition by key() partitions 1;
+
+--disable_query_log
+let $i = 100;
+while ($i)
+{
+ eval insert into t1 (a1,b1) values ($i,$i);
+ eval insert into t2 (b2,c2) values ($i mod 2, $i div 2);
+ dec $i;
+}
+--enable_query_log
+
+--echo # table t1 is only for forcing record by key count for table t2 that should be near 50 (not 1)
+analyze table t1, t2;
+# Hide Extra column
+--replace_column 10 #
+explain select * from t1, t2 where b2 = b1 and a1 = 1;
+
+drop table t1, t2;
+
set @is_enable = @is_enable_default;
source ndb_index_stat_enable.inc;
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2011-08-25 06:30:20 +0000
+++ b/sql/ha_ndbcluster.cc 2011-08-29 06:49:36 +0000
@@ -1358,19 +1358,22 @@ void ha_ndbcluster::set_rec_per_key()
*/
for (uint i=0 ; i < table_share->keys ; i++)
{
+ bool is_unique_index= false;
KEY* key_info= table->key_info + i;
switch (get_index_type(i))
{
- case UNIQUE_ORDERED_INDEX:
- case PRIMARY_KEY_ORDERED_INDEX:
case UNIQUE_INDEX:
case PRIMARY_KEY_INDEX:
{
// Index is unique when all 'key_parts' are specified,
// else distribution is unknown and not specified here.
- key_info->rec_per_key[key_info->key_parts-1]= 1;
+ is_unique_index= true;
break;
}
+ case UNIQUE_ORDERED_INDEX:
+ case PRIMARY_KEY_ORDERED_INDEX:
+ is_unique_index= true;
+ // intentional fall thru to logic for ordered index
case ORDERED_INDEX:
// 'Records pr. key' are unknown for non-unique indexes.
// (May change when we get better index statistics.)
@@ -1400,6 +1403,11 @@ void ha_ndbcluster::set_rec_per_key()
default:
DBUG_ASSERT(false);
}
+ // set rows per key to 1 for complete key given for unique/primary index
+ if (is_unique_index)
+ {
+ key_info->rec_per_key[key_info->key_parts-1]= 1;
+ }
}
DBUG_VOID_RETURN;
}
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.1-telco-7.1 branch (jonas.oreland:4261 to 4262) | Jonas Oreland | 29 Aug |