表结构
c_tag_word 表(id,word)
c_movie_tag_director (aid,tagid)
select word from c_tag_word
where exists(
select 1 from c_movie_tag_director where aid= '1209' and tagid=c_tag_word.id
)类似这样的语句,一个php页面中要执行 100次,执行每一句 我这边用时0.2秒,打开一个PHP页面 执行100次,光这个mysql查询就要20秒的时候,这个有什么方法可以解决?
c_tag_word 表(id,word)
c_movie_tag_director (aid,tagid)
select word from c_tag_word
where exists(
select 1 from c_movie_tag_director where aid= '1209' and tagid=c_tag_word.id
)类似这样的语句,一个php页面中要执行 100次,执行每一句 我这边用时0.2秒,打开一个PHP页面 执行100次,光这个mysql查询就要20秒的时候,这个有什么方法可以解决?
show create table c_tag_word;
show create table c_movie_tag_director;show index from c_tag_word;
show index from c_movie_tag_director;
CREATE TABLE `c_tag_word` (
`id` int(11) NOT NULL auto_increment,
`word` varchar(255) default NULL,
PRIMARY KEY (`id`),
KEY `word` (`word`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8CREATE TABLE `c_movie_tag_director` (
`aid` int(11) NOT NULL default '0',
`tagid` int(11) default NULL,
KEY `tagid` (`tagid`),
KEY `aid` (`aid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8c_tag_word 0 PRIMARY 1 id A 8908 NULL NULL BTREE
c_tag_word 1 word 1 word A NULL NULL NULL YES BTREE c_movie_tag_director 1 tagid 1 tagid A 646 NULL NULL YES BTREE
c_movie_tag_director 1 aid 1 aid A 2585 NULL NULL BTREE
from c_tag_word a,c_movie_tag_director b
where a.id=b.tagid and b.aid= '1209'