Hello,
On the top of page 316, there is: … Therefore, if we add indexes for tbl_post.status
and tbl_post.create_time, it will improve SELECT performance, as shown in
the following screenshot:
It should be tbl_comment
in both cases instead of tbl_post
. In the following query t
is alias of tbl_comment
:
SELECT `t`.`id` AS `t0_c0`, `t`.`content` AS `t0_c1`, `t`.`status` AS `t0_c2`, `t`.`create_time` AS `t0_c3`, `t`.`author` AS `t0_c4`, `t`.`email` AS `t0_c5`, `t`.`url` AS `t0_c6`, `t`.`post_id` AS `t0_c7`, `post`.`id` AS `t1_c0`, `post`.`title` AS `t1_c1`, `post`.`content` AS `t1_c2`, `post`.`tags` AS `t1_c3`, `post`.`status` AS `t1_c4`, `post`.`create_time` AS `t1_c5`, `post`.`update_time` AS `t1_c6`, `post`.`author_id` AS `t1_c7`
FROM `tbl_comment` `t`
LEFT OUTER JOIN `tbl_post` `post` ON (`t`.`post_id`=`post`.`id`)
WHERE (t.status=2)
ORDER BY t.create_time DESC
LIMIT 10