MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:igor Date:February 2 2007 11:22pm
Subject:bk commit into 5.0 tree (igor:1.2400) BUG#24035
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor 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@stripped, 2007-02-02 15:22:10-08:00, igor@stripped +3 -0
  Fix bug #24035.
  This performance degradation for UPDATEs could be observed in the update
  statements for which the search key cannot be converted to any valid
  value of the type of the search column, like for a  the condition
  int_fld=99999999999999999999999999, though it can be guaranteed here
  that there is no row with such a key value. 

  mysql-test/r/update.result@stripped, 2007-02-02 15:22:08-08:00, igor@stripped +57 -0
    Added a test case for bug #24035.

  mysql-test/t/update.test@stripped, 2007-02-02 15:22:08-08:00, igor@stripped +35 -0
    Added a test case for bug #24035.

  sql/opt_range.cc@stripped, 2007-02-02 15:22:08-08:00, igor@stripped +16 -1
    Fix bug #24035.
    This performance degradation for could be observed in the update
    statements for which the search key cannot be converted to any valid
    value of the type of the search column, like for a  the condition
    int_fld=99999999999999999999999999, though it can be guaranteed here
    that there is no row with such a key value. 
    Now the function get_mm_leaf creates trees of the type SEL_ARG::IMPOSSIBLE 
    for such conditions that tells the range scan not to perform any search
    at all.  

# 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:	igor
# Host:	olga.mysql.com
# Root:	/home/igor/dev-opt/mysql-5.0-opt-bug24035

--- 1.238/sql/opt_range.cc	2007-02-02 15:22:16 -08:00
+++ 1.239/sql/opt_range.cc	2007-02-02 15:22:16 -08:00
@@ -4296,7 +4296,22 @@
   err= value->save_in_field_no_warnings(field, 1);
   if (err > 0 && field->cmp_type() != value->result_type())
   {
-    tree= 0;
+    if ((type == Item_func::EQ_FUNC || type == Item_func::EQUAL_FUNC) &&
+	value->result_type() == item_cmp_type(field->result_type(),
+                                              value->result_type()))
+
+    {
+      tree= new (alloc) SEL_ARG(field, 0, 0);
+      tree->type= SEL_ARG::IMPOSSIBLE;
+    }
+    else
+    {
+      /*
+        TODO: We should return trees of the type SEL_ARG::IMPOSSIBLE
+        for the cases like int_field > 999999999999999999999999 as well.
+      */
+      tree= 0;
+    }
     goto end;
   } 
   if (err < 0)

--- 1.30/mysql-test/r/update.result	2007-02-02 15:22:16 -08:00
+++ 1.31/mysql-test/r/update.result	2007-02-02 15:22:16 -08:00
@@ -377,3 +377,60 @@
 insert into t1 values (1,1);
 update t1 set `*f2`=1;
 drop table t1;
+CREATE TABLE t1 (
+request_id int unsigned NOT NULL auto_increment,
+user_id varchar(12) default NULL,
+time_stamp datetime NOT NULL default '0000-00-00 00:00:00',
+ip_address varchar(15) default NULL,
+PRIMARY KEY (request_id),
+KEY user_id_2 (user_id,time_stamp)
+);
+INSERT INTO t1 (user_id) VALUES ('user1');
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+flush status;
+SELECT user_id FROM t1 WHERE request_id=9999999999999;
+user_id
+show status like '%Handler_read%';
+Variable_name	Value
+Handler_read_first	0
+Handler_read_key	1
+Handler_read_next	0
+Handler_read_prev	0
+Handler_read_rnd	0
+Handler_read_rnd_next	0
+SELECT user_id FROM t1 WHERE request_id=999999999999999999999999999999;
+user_id
+show status like '%Handler_read%';
+Variable_name	Value
+Handler_read_first	0
+Handler_read_key	2
+Handler_read_next	0
+Handler_read_prev	0
+Handler_read_rnd	0
+Handler_read_rnd_next	7
+UPDATE t1 SET user_id=null WHERE request_id=9999999999999;
+show status like '%Handler_read%';
+Variable_name	Value
+Handler_read_first	0
+Handler_read_key	3
+Handler_read_next	0
+Handler_read_prev	0
+Handler_read_rnd	0
+Handler_read_rnd_next	14
+UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999;
+show status like '%Handler_read%';
+Variable_name	Value
+Handler_read_first	0
+Handler_read_key	3
+Handler_read_next	0
+Handler_read_prev	0
+Handler_read_rnd	0
+Handler_read_rnd_next	21
+DROP TABLE t1;

--- 1.28/mysql-test/t/update.test	2007-02-02 15:22:16 -08:00
+++ 1.29/mysql-test/t/update.test	2007-02-02 15:22:16 -08:00
@@ -307,3 +307,38 @@
 update t1 set `*f2`=1;
 drop table t1;
 # End of 4.1 tests
+
+#
+# Bug #24035: performance degradation with condition int_field=big_decimal
+#
+
+CREATE TABLE t1 (
+  request_id int unsigned NOT NULL auto_increment,
+  user_id varchar(12) default NULL,
+  time_stamp datetime NOT NULL default '0000-00-00 00:00:00',
+  ip_address varchar(15) default NULL,
+  PRIMARY KEY (request_id),
+  KEY user_id_2 (user_id,time_stamp)
+);
+
+INSERT INTO t1 (user_id) VALUES ('user1');
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+INSERT INTO t1(user_id) SELECT user_id FROM t1;
+
+flush status;
+SELECT user_id FROM t1 WHERE request_id=9999999999999; 
+show status like '%Handler_read%';
+SELECT user_id FROM t1 WHERE request_id=999999999999999999999999999999; 
+show status like '%Handler_read%';
+UPDATE t1 SET user_id=null WHERE request_id=9999999999999;
+show status like '%Handler_read%';
+UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999;
+show status like '%Handler_read%';
+
+DROP TABLE t1;
Thread
bk commit into 5.0 tree (igor:1.2400) BUG#24035igor3 Feb