Re: Optimizer being overly aggressive
Interesting.
A guess... The "SELECT * FROM mydata" is "lazily" compiled, but then then it is remembered in the SP. That is, the first time, it decides that "*" is "col1", and it saves that. The second call fails to re-"compile" that statement.
Plan A: Write a bug report (bugs.mysql.com)
Plan B: PREPARE & EXECUTE the SELECT *
Plan C: Use an alias to avoid the problem:
SET @s=CONCAT('CREATE TEMPORARY TABLE mydata AS SELECT ', @mycol, ' AS the_col FROM foo');
...
SELECT the_col FROM mydata;
Plan D: Use a subquery rather than an explicit temp table.
Subject
Views
Written By
Posted
2860
July 06, 2012 08:18PM
Re: Optimizer being overly aggressive
1451
July 10, 2012 12:49PM
1435
July 10, 2012 08:54PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.