• gkodinov@mysql.com's avatar
    * Bug #9676: INSERT INTO x SELECT .. FROM x LIMIT 1; slows down with big · c5ed7a87
    gkodinov@mysql.com authored
                  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.
    c5ed7a87
sql_select.cc 289 KB