0
所以我的老板给了我一个需要优化的存储过程,因为它很慢。该过程正在创建临时表,并且看起来很奇怪:临时表是否可以在MySQL中重用?
/* pseudocode for brevity */
create temp_table;
insert into temp_table (...)
select ...
from other_table
inner join ...
inner join ...
where condition
select * from temp_table
就这样。该代码只将数据插入临时表中,以便立即检索。下面是我做什么,我删除临时表,并直接返回所选择的记录:
/* pseudocode for brevity */
select ...
from other_table
inner join ...
inner join ...
where condition
代码之前看起来错了,但我想,以确保临时表做什么。所以我读了临时表,并认为临时表可以持续使用,只能在一次会话中访问。我的问题:
- 会话是什么意思?当我在应用程序端并打开连接时,是否可以重用临时表?我想知道这是为什么这里有临时表。
https://dba.stackexchange.com/a/57976/10827 –