惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - ringwang

【转】 软件需求分析的工作步骤和流程 【转】软件需求分析方法 大网站安全防护措施解读【转】 互联网金融安全1【转】 python环境下载地址 批处理脚本学习 自动复制部署 苹果系统里面部署ASP.NET 23种设计模式的基本介绍 .NET MVC控制器分离到类库的方法 【转】MySQL 性能优化的最佳20多条经验分享 【转】ASP.NET MVC IOC 之AutoFac攻略 【转】WCF与Web API 区别(应用场景) windows系统命令服务安装卸载 Mysql字段操作—增加字段、删除字段、修改字段名、修改字段类型(约束条件) 【转】 使用lftp传输文件的shell脚本 Oracle异常处理,动态游标 java读取文件批量插入记录 linux vmstat 系统结果说明
MYSQL临时表创建索引
ringwang · 2015-08-12 · via 博客园 - ringwang

DROP TEMPORARY TABLE IF EXISTS tmp_record_t2;
CREATE TEMPORARY TABLE tmp_record_t2
(
consumption_id INT(11) UNSIGNED NOT NULL,-- 店铺ID
created_org INT,
return_money DECIMAL(11,2),-- 退菜金额
cash DECIMAL(11,2),-- 现金
member_card DECIMAL(11,2),-- 会员卡
bank_card DECIMAL(11,2),-- 银行卡
credit DECIMAL(11,2),-- 挂账
free DECIMAL(11,2),-- 免??
ticket DECIMAL(11,2),-- 票券
foregift DECIMAL(11,2), -- 订金
wxzf DECIMAL(11,2), -- 微信支付
KEY pk(consumption_id) -- 创建索引,这个在临时表关联的时候非常重要,可以提高速度10倍
)ENGINE=MEMORY DEFAULT CHARSET=utf8 ;

tablestr2为动态的语句,将结果插入到临时表

SET @exe_sql = CONCAT('INSERT INTO tmp_record_t2 ',@tablestr2);
PREPARE stmt FROM @exe_sql ;
EXECUTE stmt ;

临时表默认的方式是 MyISAM

但是 MEMORY比MyISAM快大概20%。 所以指定MEMORY方式

 参考:http://wenku.baidu.com/link?url=h1rkLZdfavLLboTr9jph_l5MGcxyj5_E9f2tXss-l8ZWCvlvHIOuqu5N1qlvfwwdctDYQ7FqY9G7iZwQXV78oK0rorE7DTXIEwna3Dp5aqK