Yii Framework Forum: Possible Wrong Table Name - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Possible Wrong Table Name Chapter 11: Performance Tuning, page 316

#1 User is offline   yasen 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 29-October 11
  • Location:Sofia, Bulgaria

Posted 03 May 2012 - 01:32 AM

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

0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,387
  • Joined: 17-January 09
  • Location:Russia

Posted 03 May 2012 - 02:30 AM

Good catch. Added to errata page on the book website. Thanks.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users