Below is the list of changes that have just been committed into a local
4.1 repository of kgeorge. When kgeorge 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.2489 06/06/15 18:26:50 gkodinov@stripped +3 -0
* Bug #9676: INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big
tables
Currently in INSERT ... SELECT ... LIMIT ... the compiler uses a
temporary table to store the results of SELECT ... LIMIT .. and then
uses that table as a source for INSERT. The problem is that in some cases
it actually skips the LIMIT clause in doing that and materializes the
whole SELECT result set regardless of the LIMIT.
This fix is limiting the process of filling up the temp table with only
that much rows that will be actually used by propagating the LIMIT value.
sql/sql_select.cc
1.456 06/06/15 18:26:45 gkodinov@stripped +8 -4
* Bug #9676: INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big
tables
- pass through the real LIMIT number if the temp table is created for
buffering results.
- set the counter for all the cases when the temp table is not used for
grouping
mysql-test/t/insert_select.test
1.24 06/06/15 18:26:45 gkodinov@stripped +13 -0
* Bug #9676: INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big
tables
- a test demonstrating the code path
mysql-test/r/insert_select.result
1.30 06/06/15 18:26:45 gkodinov@stripped +4 -0
* Bug #9676: INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big
tables
- a test demonstrating the code path
# 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: gkodinov
# Host: rakia.(none)
# Root: /home/kgeorge/mysql/4.1/B9676
--- 1.455/sql/sql_select.cc 2006-06-03 00:14:52 +03:00
+++ 1.456/sql/sql_select.cc 2006-06-15 18:26:45 +03:00
@@ -888,8 +888,9 @@
group_list ? 0 : select_distinct,
group_list && simple_group,
select_options,
- (order == 0 || skip_sort_order) ? select_limit :
- HA_POS_ERROR,
+ (order == 0 || skip_sort_order ||
+ test(select_options & OPTION_BUFFER_RESULT)) ?
+ select_limit : HA_POS_ERROR,
(char *) "")))
DBUG_RETURN(1);
@@ -5530,6 +5531,11 @@
keyinfo->key_length+= key_part_info->length;
}
}
+ else
+ {
+ set_if_smaller(table->max_rows, rows_limit);
+ param->end_write_records= rows_limit;
+ }
if (distinct && field_count != param->hidden_field_count)
{
@@ -5544,8 +5550,6 @@
null_pack_length-=hidden_null_pack_length;
keyinfo->key_parts= ((field_count-param->hidden_field_count)+
test(null_pack_length));
- set_if_smaller(table->max_rows, rows_limit);
- param->end_write_records= rows_limit;
table->distinct=1;
table->keys=1;
if (blob_count)
--- 1.29/mysql-test/r/insert_select.result 2005-10-25 19:02:11 +03:00
+++ 1.30/mysql-test/r/insert_select.result 2006-06-15 18:26:45 +03:00
@@ -686,3 +686,7 @@
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
ERROR 42S02: Unknown table 't2' in field list
drop table t1,t2;
+CREATE TABLE t1 (a int PRIMARY KEY);
+INSERT INTO t1 values (1), (2);
+INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
+DROP TABLE t1;
--- 1.23/mysql-test/t/insert_select.test 2005-10-25 19:02:30 +03:00
+++ 1.24/mysql-test/t/insert_select.test 2006-06-15 18:26:45 +03:00
@@ -226,4 +226,17 @@
insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x);
drop table t1,t2;
+#
+# Bug #9676: INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big
+# tables
+#
+
+#Note: not an exsaustive test : just a check of the code path.
+CREATE TABLE t1 (a int PRIMARY KEY);
+INSERT INTO t1 values (1), (2);
+
+INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
+
+DROP TABLE t1;
+
# End of 4.1 tests
Thread |
---|
• bk commit into 4.1 tree (gkodinov:1.2489) BUG#9676 | kgeorge | 15 Jun |