List:Internals« Previous MessageNext Message »
From:pekka Date:September 1 2005 1:54pm
Subject:bk commit into 5.1 tree (pekka:1.1908)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of pekka. When pekka does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1908 05/09/01 15:54:07 pekka@stripped +7 -0
  ndb - wl#2624 add ndb_index_stat_% variables + small fix

  sql/sql_class.h
    1.257 05/09/01 15:32:25 pekka@stripped +3 -0
    wl#2624 add ndb_index_stat_% variables

  sql/set_var.cc
    1.130 05/09/01 15:32:25 pekka@stripped +16 -1
    wl#2624 add ndb_index_stat_% variables

  sql/mysqld.cc
    1.476 05/09/01 15:32:24 pekka@stripped +25 -0
    wl#2624 add ndb_index_stat_% variables

  sql/ha_ndbcluster.cc
    1.209 05/09/01 15:32:24 pekka@stripped +11 -4
    wl#2624 add ndb_index_stat_% variables

  mysql-test/t/ndb_index_ordered.test
    1.25 05/09/01 15:32:24 pekka@stripped +73 -0
    wl#2624 add ndb_index_stat_% variables

  mysql-test/r/ndb_index_ordered.result
    1.22 05/09/01 15:32:24 pekka@stripped +137 -0
    wl#2624 add ndb_index_stat_% variables

  storage/ndb/src/ndbapi/NdbIndexStat.cpp
    1.3 05/09/01 15:29:49 pekka@stripped +4 -2
    wl#2624 fix strict upper bound comparison

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	pekka
# Host:	clam.ndb.mysql.com
# Root:	/export/space/pekka/ndb/version/my51

--- 1.475/sql/mysqld.cc	2005-08-25 18:49:41 +02:00
+++ 1.476/sql/mysqld.cc	2005-09-01 15:32:24 +02:00
@@ -4330,6 +4330,8 @@
   OPT_NDB_SHM, OPT_NDB_OPTIMIZED_NODE_SELECTION, OPT_NDB_CACHE_CHECK_TIME,
   OPT_NDB_MGMD, OPT_NDB_NODEID,
   OPT_NDB_DISTRIBUTION,
+  OPT_NDB_INDEX_STAT_ENABLE,
+  OPT_NDB_INDEX_STAT_CACHE_ENTRIES, OPT_NDB_INDEX_STAT_UPDATE_FREQ,
   OPT_SKIP_SAFEMALLOC,
   OPT_TEMP_POOL, OPT_TX_ISOLATION, OPT_COMPLETION_TYPE,
   OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
@@ -4938,6 +4940,23 @@
     "A dedicated thread is created to, at the given millisecons interval, invalidate the query cache if another MySQL server in the cluster has changed the data in the database.",
     (gptr*) &opt_ndb_cache_check_time, (gptr*) &opt_ndb_cache_check_time, 0, GET_ULONG, REQUIRED_ARG,
     0, 0, LONG_TIMEOUT, 0, 1, 0},
+  {"ndb-index-stat-enable", OPT_NDB_INDEX_STAT_ENABLE,
+   "Use ndb index statistics in query optimization.",
+   (gptr*) &global_system_variables.ndb_index_stat_enable,
+   (gptr*) &max_system_variables.ndb_index_stat_enable,
+   0, GET_BOOL, OPT_ARG, 1, 0, 1, 0, 0, 0},
+  {"ndb-index-stat-cache-entries", OPT_NDB_INDEX_STAT_CACHE_ENTRIES,
+   "Number of start/end keys to store in statistics memory cache."
+    " Zero means no cache and forces query of db nodes always.",
+   (gptr*) &global_system_variables.ndb_index_stat_cache_entries,
+   (gptr*) &max_system_variables.ndb_index_stat_cache_entries,
+   0, GET_ULONG, OPT_ARG, 32, 0, ~0L, 0, 0, 0},
+  {"ndb-index-stat-update-freq", OPT_NDB_INDEX_STAT_UPDATE_FREQ,
+   "How often, in the long run, to query db nodes instead of statistics cache."
+   " For example 20 means every 20th time.",
+   (gptr*) &global_system_variables.ndb_index_stat_update_freq,
+   (gptr*) &max_system_variables.ndb_index_stat_update_freq,
+   0, GET_ULONG, OPT_ARG, 20, 0, ~0L, 0, 0, 0},
 #endif
   {"new", 'n', "Use very new possible 'unsafe' functions.",
    (gptr*) &global_system_variables.new_mode,
@@ -6200,6 +6219,12 @@
 #endif
 #ifdef HAVE_NDBCLUSTER_DB
   have_ndbcluster=SHOW_OPTION_DISABLED;
+  global_system_variables.ndb_index_stat_enable=TRUE;
+  max_system_variables.ndb_index_stat_enable=TRUE;
+  global_system_variables.ndb_index_stat_cache_entries=32;
+  max_system_variables.ndb_index_stat_cache_entries=~0L;
+  global_system_variables.ndb_index_stat_update_freq=20;
+  max_system_variables.ndb_index_stat_update_freq=~0L;
 #else
   have_ndbcluster=SHOW_OPTION_NO;
 #endif

--- 1.256/sql/sql_class.h	2005-08-25 18:49:42 +02:00
+++ 1.257/sql/sql_class.h	2005-09-01 15:32:25 +02:00
@@ -561,6 +561,9 @@
   my_bool ndb_force_send;
   my_bool ndb_use_exact_count;
   my_bool ndb_use_transactions;
+  my_bool ndb_index_stat_enable;
+  ulong ndb_index_stat_cache_entries;
+  ulong ndb_index_stat_update_freq;
 #endif /* HAVE_NDBCLUSTER_DB */
   my_bool old_alter_table;
   my_bool old_passwords;

--- 1.21/mysql-test/r/ndb_index_ordered.result	2005-02-16 21:09:03 +01:00
+++ 1.22/mysql-test/r/ndb_index_ordered.result	2005-09-01 15:32:24 +02:00
@@ -652,3 +652,140 @@
 Tables_in_test
 t1
 drop table t1;
+set autocommit=1;
+show session variables like 'ndb_index_stat_%';
+Variable_name	Value
+ndb_index_stat_cache_entries	32
+ndb_index_stat_enable	ON
+ndb_index_stat_update_freq	20
+set ndb_index_stat_enable = off;
+show session variables like 'ndb_index_stat_%';
+Variable_name	Value
+ndb_index_stat_cache_entries	32
+ndb_index_stat_enable	OFF
+ndb_index_stat_update_freq	20
+create table t1 (a int, b int, c varchar(10) not null,
+primary key using hash (a), index(b,c)) engine=ndb;
+insert into t1 values
+(1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'),
+(4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'),
+(7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc');
+select count(*) from t1 where b < 10;
+count(*)
+0
+select count(*) from t1 where b >= 10 and c >= 'bbb';
+count(*)
+6
+select count(*) from t1 where b > 10;
+count(*)
+6
+select count(*) from t1 where b <= 20 and c < 'ccc';
+count(*)
+4
+select count(*) from t1 where b = 20 and c = 'ccc';
+count(*)
+1
+select count(*) from t1 where b > 20;
+count(*)
+3
+select count(*) from t1 where b = 30 and c > 'aaa';
+count(*)
+2
+select count(*) from t1 where b <= 20;
+count(*)
+6
+select count(*) from t1 where b >= 20 and c > 'aaa';
+count(*)
+4
+drop table t1;
+set ndb_index_stat_enable = on;
+set ndb_index_stat_cache_entries = 0;
+show session variables like 'ndb_index_stat_%';
+Variable_name	Value
+ndb_index_stat_cache_entries	0
+ndb_index_stat_enable	ON
+ndb_index_stat_update_freq	20
+create table t1 (a int, b int, c varchar(10) not null,
+primary key using hash (a), index(b,c)) engine=ndb;
+insert into t1 values
+(1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'),
+(4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'),
+(7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc');
+select count(*) from t1 where b < 10;
+count(*)
+0
+select count(*) from t1 where b >= 10 and c >= 'bbb';
+count(*)
+6
+select count(*) from t1 where b > 10;
+count(*)
+6
+select count(*) from t1 where b <= 20 and c < 'ccc';
+count(*)
+4
+select count(*) from t1 where b = 20 and c = 'ccc';
+count(*)
+1
+select count(*) from t1 where b > 20;
+count(*)
+3
+select count(*) from t1 where b = 30 and c > 'aaa';
+count(*)
+2
+select count(*) from t1 where b <= 20;
+count(*)
+6
+select count(*) from t1 where b >= 20 and c > 'aaa';
+count(*)
+4
+drop table t1;
+set ndb_index_stat_enable = on;
+set ndb_index_stat_cache_entries = 4;
+set ndb_index_stat_update_freq = 2;
+show session variables like 'ndb_index_stat_%';
+Variable_name	Value
+ndb_index_stat_cache_entries	4
+ndb_index_stat_enable	ON
+ndb_index_stat_update_freq	2
+create table t1 (a int, b int, c varchar(10) not null,
+primary key using hash (a), index(b,c)) engine=ndb;
+insert into t1 values
+(1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'),
+(4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'),
+(7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc');
+select count(*) from t1 where b < 10;
+count(*)
+0
+select count(*) from t1 where b >= 10 and c >= 'bbb';
+count(*)
+6
+select count(*) from t1 where b > 10;
+count(*)
+6
+select count(*) from t1 where b <= 20 and c < 'ccc';
+count(*)
+4
+select count(*) from t1 where b = 20 and c = 'ccc';
+count(*)
+1
+select count(*) from t1 where b > 20;
+count(*)
+3
+select count(*) from t1 where b = 30 and c > 'aaa';
+count(*)
+2
+select count(*) from t1 where b <= 20;
+count(*)
+6
+select count(*) from t1 where b >= 20 and c > 'aaa';
+count(*)
+4
+drop table t1;
+set ndb_index_stat_enable = @@global.ndb_index_stat_enable;
+set ndb_index_stat_cache_entries = @@global.ndb_index_stat_cache_entries;
+set ndb_index_stat_update_freq = @@global.ndb_index_stat_update_freq;
+show session variables like 'ndb_index_stat_%';
+Variable_name	Value
+ndb_index_stat_cache_entries	32
+ndb_index_stat_enable	ON
+ndb_index_stat_update_freq	20

--- 1.24/mysql-test/t/ndb_index_ordered.test	2005-07-28 15:12:35 +02:00
+++ 1.25/mysql-test/t/ndb_index_ordered.test	2005-09-01 15:32:24 +02:00
@@ -349,4 +349,77 @@
 show tables;
 drop table t1;
 
+# -- index statistics --
+
+set autocommit=1;
+show session variables like 'ndb_index_stat_%';
+
+set ndb_index_stat_enable = off;
+show session variables like 'ndb_index_stat_%';
+
+create table t1 (a int, b int, c varchar(10) not null,
+  primary key using hash (a), index(b,c)) engine=ndb;
+insert into t1 values
+  (1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'),
+  (4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'),
+  (7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc');
+select count(*) from t1 where b < 10;
+select count(*) from t1 where b >= 10 and c >= 'bbb';
+select count(*) from t1 where b > 10;
+select count(*) from t1 where b <= 20 and c < 'ccc';
+select count(*) from t1 where b = 20 and c = 'ccc';
+select count(*) from t1 where b > 20;
+select count(*) from t1 where b = 30 and c > 'aaa';
+select count(*) from t1 where b <= 20;
+select count(*) from t1 where b >= 20 and c > 'aaa';
+drop table t1;
+
+set ndb_index_stat_enable = on;
+set ndb_index_stat_cache_entries = 0;
+show session variables like 'ndb_index_stat_%';
+
+create table t1 (a int, b int, c varchar(10) not null,
+  primary key using hash (a), index(b,c)) engine=ndb;
+insert into t1 values
+  (1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'),
+  (4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'),
+  (7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc');
+select count(*) from t1 where b < 10;
+select count(*) from t1 where b >= 10 and c >= 'bbb';
+select count(*) from t1 where b > 10;
+select count(*) from t1 where b <= 20 and c < 'ccc';
+select count(*) from t1 where b = 20 and c = 'ccc';
+select count(*) from t1 where b > 20;
+select count(*) from t1 where b = 30 and c > 'aaa';
+select count(*) from t1 where b <= 20;
+select count(*) from t1 where b >= 20 and c > 'aaa';
+drop table t1;
+
+set ndb_index_stat_enable = on;
+set ndb_index_stat_cache_entries = 4;
+set ndb_index_stat_update_freq = 2;
+show session variables like 'ndb_index_stat_%';
+
+create table t1 (a int, b int, c varchar(10) not null,
+  primary key using hash (a), index(b,c)) engine=ndb;
+insert into t1 values
+  (1,10,'aaa'),(2,10,'bbb'),(3,10,'ccc'),
+  (4,20,'aaa'),(5,20,'bbb'),(6,20,'ccc'),
+  (7,30,'aaa'),(8,30,'bbb'),(9,30,'ccc');
+select count(*) from t1 where b < 10;
+select count(*) from t1 where b >= 10 and c >= 'bbb';
+select count(*) from t1 where b > 10;
+select count(*) from t1 where b <= 20 and c < 'ccc';
+select count(*) from t1 where b = 20 and c = 'ccc';
+select count(*) from t1 where b > 20;
+select count(*) from t1 where b = 30 and c > 'aaa';
+select count(*) from t1 where b <= 20;
+select count(*) from t1 where b >= 20 and c > 'aaa';
+drop table t1;
+
+set ndb_index_stat_enable = @@global.ndb_index_stat_enable;
+set ndb_index_stat_cache_entries = @@global.ndb_index_stat_cache_entries;
+set ndb_index_stat_update_freq = @@global.ndb_index_stat_update_freq;
+show session variables like 'ndb_index_stat_%';
+
 # End of 4.1 tests

--- 1.208/sql/ha_ndbcluster.cc	2005-08-31 14:14:02 +02:00
+++ 1.209/sql/ha_ndbcluster.cc	2005-09-01 15:32:24 +02:00
@@ -1077,14 +1077,21 @@
       NDB_INDEX_DATA& d=m_index[i];
       delete d.index_stat;
       d.index_stat=NULL;
-      THD *thd=current_thd; // not yet
-      if (true)
+      THD *thd=current_thd;
+      if (thd->variables.ndb_index_stat_enable)
       {
         d.index_stat=new NdbIndexStat(index);
-        d.index_stat_cache_entries=32;
-        d.index_stat_update_freq=10;
+        d.index_stat_cache_entries=thd->variables.ndb_index_stat_cache_entries;
+        d.index_stat_update_freq=thd->variables.ndb_index_stat_update_freq;
         d.index_stat_query_count=0;
         d.index_stat->alloc_cache(d.index_stat_cache_entries);
+        DBUG_PRINT("info", ("index %s stat=on cache_entries=%u update_freq=%u",
+                            index->getName(),
+                            d.index_stat_cache_entries,
+                            d.index_stat_update_freq));
+      } else
+      {
+        DBUG_PRINT("info", ("index %s stat=off", index->getName()));
       }
     }
     if (idx_type == UNIQUE_ORDERED_INDEX || idx_type == UNIQUE_INDEX)

--- 1.129/sql/set_var.cc	2005-08-25 18:49:41 +02:00
+++ 1.130/sql/set_var.cc	2005-09-01 15:32:25 +02:00
@@ -435,6 +435,15 @@
 sys_ndb_use_transactions("ndb_use_transactions", &SV::ndb_use_transactions);
 sys_var_long_ptr
 sys_ndb_cache_check_time("ndb_cache_check_time", &ndb_cache_check_time);
+sys_var_thd_bool
+sys_ndb_index_stat_enable("ndb_index_stat_enable",
+                          &SV::ndb_index_stat_enable);
+sys_var_thd_ulong
+sys_ndb_index_stat_cache_entries("ndb_index_stat_cache_entries",
+                                 &SV::ndb_index_stat_cache_entries);
+sys_var_thd_ulong
+sys_ndb_index_stat_update_freq("ndb_index_stat_update_freq",
+                               &SV::ndb_index_stat_update_freq);
 #endif
 
 /* Time/date/datetime formats */
@@ -723,6 +732,9 @@
   &sys_ndb_force_send,
   &sys_ndb_use_exact_count,
   &sys_ndb_use_transactions,
+  &sys_ndb_index_stat_enable,
+  &sys_ndb_index_stat_cache_entries,
+  &sys_ndb_index_stat_update_freq,
 #endif
   &sys_unique_checks,
   &sys_updatable_views_with_limit,
@@ -904,10 +916,13 @@
 #ifdef HAVE_NDBCLUSTER_DB
   {sys_ndb_autoincrement_prefetch_sz.name,
    (char*) &sys_ndb_autoincrement_prefetch_sz,                      SHOW_SYS},
+  {sys_ndb_cache_check_time.name,(char*) &sys_ndb_cache_check_time, SHOW_SYS},
   {sys_ndb_force_send.name,   (char*) &sys_ndb_force_send,          SHOW_SYS},
+  {sys_ndb_index_stat_cache_entries.name, (char*) &sys_ndb_index_stat_cache_entries, SHOW_SYS},
+  {sys_ndb_index_stat_enable.name, (char*) &sys_ndb_index_stat_enable, SHOW_SYS},
+  {sys_ndb_index_stat_update_freq.name, (char*) &sys_ndb_index_stat_update_freq, SHOW_SYS},
   {sys_ndb_use_exact_count.name,(char*) &sys_ndb_use_exact_count,   SHOW_SYS},
   {sys_ndb_use_transactions.name,(char*) &sys_ndb_use_transactions, SHOW_SYS},
-  {sys_ndb_cache_check_time.name,(char*) &sys_ndb_cache_check_time, SHOW_SYS},
 #endif
   {sys_net_buffer_length.name,(char*) &sys_net_buffer_length,       SHOW_SYS},
   {sys_net_read_timeout.name, (char*) &sys_net_read_timeout,        SHOW_SYS},

--- 1.2/storage/ndb/src/ndbapi/NdbIndexStat.cpp	2005-08-31 14:11:37 +02:00
+++ 1.3/storage/ndb/src/ndbapi/NdbIndexStat.cpp	2005-09-01 15:29:49 +02:00
@@ -51,6 +51,8 @@
     keysize += (c->m_attrSize * c->m_arraySize + 3 ) / 4;
   }
   Uint32 areasize = entries * (PointerSize + EntrySize + keysize);
+  if (areasize > (1 << 16))
+    areasize = (1 << 16);
   Uint32 cachesize = 2 * areasize;
   m_cache = new Uint32 [cachesize];
   if (m_cache == NULL) {
@@ -190,10 +192,10 @@
     k++;
   }
   if (ret == 0) {
-    // strict is bigger
+    // strict bound is greater as start key and less as end key
     int s1 = t1 & 1;
     int s2 = t2 & 1;
-    ret = s1 - s2;
+    ret = (s1 - s2) * jdir;
   }
   return ret;
 }
Thread
bk commit into 5.1 tree (pekka:1.1908)pekka1 Sep