MySQL Forums
Forum List  »  Optimizer & Parser

Re: Optimizer being overly aggressive
Posted by: Rick James
Date: July 10, 2012 12:49PM

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.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Optimizer being overly aggressive
1374
July 10, 2012 12:49PM


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.