From c5ed7a87f42259ddf853d9a9c16e0596f7aa9983 Mon Sep 17 00:00:00 2001 From: "gkodinov@mysql.com" <> Date: Mon, 19 Jun 2006 13:22:42 +0300 Subject: * 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. --- mysql-test/r/insert_select.result | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mysql-test/r/insert_select.result') diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 028b40ac3b6..1d7aef256e1 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -686,3 +686,7 @@ ERROR 42S22: Unknown column 'z' in 'field list' 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; -- cgit v1.2.1