我有这个查询
SELECT
t.name,t.userid,t.date,t.cat_id,t.forum_id,t.reply,t.hidden,t.moderated,t.sticky,t.statut,t.poll,t.helpful,t.del,
t_data.message,
user.name AS author_name,user.level AS author_level,user.is_globalMod AS author_global,user.award,
user.statut AS author_statut,user.posts AS user_posts,user.point AS user_points,user.title AS user_title,
user.image AS user_avatar,user.sex AS user_sex,user.other_level,user.hid_posts
FROM frm_thread AS t
LEFT JOIN frm_thread_data AS t_data ON t_data.thread_id = t.id
LEFT JOIN frm_member AS user ON user.id =t.userid
WHERE t.id = 248925
frm_thread是
CREATE TABLE IF NOT EXISTS
frm_thread
(
id
mediumint(7) unsigned NOT NULL auto_increment,
last_userid
int(10) unsigned NOT NULL,
last_date
int(10) unsigned default NULL,
forum_id
tinyint(5) unsigned NOT NULL,
cat_id
tinyint(3) unsigned NOT NULL,
name
varchar(250) collate utf8_unicode_ci NOT NULL,
userid
int(10) unsigned NOT NULL,
date
int(10) unsigned default NULL,
view
mediumint(5) unsigned NOT NULL,
reply
smallint(4) NOT NULL,
sticky
tinyint(1) unsigned NOT NULL,
linked
tinyint(1) unsigned NOT NULL,
linked_order
tinyint(2) unsigned NOT NULL,
spam
tinyint(1) unsigned NOT NULL,
statut
tinyint(1) unsigned NOT NULL,
moderated
tinyint(1) unsigned NOT NULL,
hidden
tinyint(1) unsigned NOT NULL,
poll
smallint(5) unsigned NOT NULL,
del
tinyint(1) unsigned NOT NULL,
t_icon
smallint(10) unsigned NOT NULL,
helpful
int(10) unsigned NOT NULL
PRIMARY KEY (id
),
KEY forum_id
(forum_id
),
KEY last_date
(last_date
,date
,sticky
),
KEY linked
(linked
),
KEY date
(date
),
KEY userid
(userid
),
KEY last_userid
(last_userid
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=249014 ;
frm_thread_data
frm_thread
如您所见,消息内容位于一个单独的表中, 现在这个查询正常在0.0005中完成,由codeigniter profiling显示
某些时间需要25.0050秒我有一个帖子表,但文本字段不在一个单独的表中,它总是给出一个接近0.0020的数字
有没有办法解决这个问题?
EXPLAIN SHOW的
id select_type表类型possible_keys键key_len ref行额外
1 SIMPLE t const PRIMARY PRIMARY PRIMARY 3 const 1
1 SIMPLE t_data const PRIMARY PRIMARY 4 const 1
1 SIMPLE用户const PRIMARY PRIMARY 4 const 1
答案 0 :(得分:0)