mysql 查询优化 求解
情况如下:
select count(*) from tb_program; 共19w条
表结构
CREATE TABLE `tb_program` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`Tmpid` int(10) NOT NULL,
`Name` varchar(50) DEFAULT NULL,
`Descs` varchar(200) DEFAULT NULL,
`AddUser` varchar(50) DEFAULT NULL,
`AddTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`Remark` text,
`MovIds` varchar(50) DEFAULT NULL,
`Status` int(10) DEFAULT NULL ,
`PlayCode` varchar(100) DEFAULT NULL,
`sort` int(10) NOT NULL,
`filepath` varchar(200) DEFAULT NULL,
`cid` int(10) NOT NULL,
`fexist` tinyint(3) unsigned NOT NULL,
`veriUser` varchar(50) DEFAULT NULL,
`veriTime` timestamp NULL DEFAULT NULL,
`veriUser_dx` varchar(50) DEFAULT NULL,
`veriTime_dx` timestamp NULL DEFAULT NULL,
`veriUser_wg` varchar(50) DEFAULT NULL,
`veriTime_wg` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `PK_tb_Program` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=196001 DEFAULT CHARSET=utf8;
另外一个表 select count(*) from tb_template; 430条
表结构:
CREATE TABLE `tb_template` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`Name` varchar(100) NOT NULL,
`Descs` varchar(200) DEFAULT NULL,
`Url` varchar(200) DEFAULT NULL,
`Status` int(10) NOT NULL ,
`AddUser` varchar(50) DEFAULT NULL,
`AddTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`PlayUrl` text,
`AreaCode` varchar(10) DEFAULT NULL,
`objectId` varchar(100) DEFAULT NULL,
`Ftp` varchar(100) DEFAULT NULL,
`Title` varchar(100) DEFAULT NULL,
`Copyright` varchar(100) DEFAULT NULL,
`DefaultChannel` int(10) NOT NULL,
`Logo` varchar(100) DEFAULT NULL,
`pftype` int(10) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `PK_TB_TEMPLATE` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=471 DEFAULT CHARSET=utf8;
情况 :select tp.Name,tp.AddTime,tp.PlayCode,tp.Status,tb.Name as templatename from tb_program tp LEFT JOIN tb_template tb
on tb.id=tp.Tmpid;
共耗时 2秒多
求优化方案! (其中tb_program 表每个月大概有3w的添加)