MySQL Forums
Forum List  »  Optimizer & Parser

Re: Need help :-(
Posted by: Rick James
Date: May 19, 2009 11:24PM

SELECT  DISTINCT `Tweets`.*
    FROM  `TweetFollowers`, `Tweets`
    WHERE  ((`Tweets`.`Poster` = `TweetFollowers`.`MemberID`
      AND  `TweetFollowers`.`Follower` = '2554')
      OR  `Tweets`.`Poster` = '2554')
      AND  `Post` != ''
    ORDER BY  `Posted` DESC
    LIMIT  5;

( SELECT  t.*
    FROM  `TweetFollowers` f, Tweets t
    WHERE  t.`Poster` = f.`MemberID`
      AND  f.`Follower` = '2554'
      AND  `Post` != ''
    ORDER BY  `Posted` DESC
    LIMIT  5
) 
UNION DISTINCT
( SELECT  t.*
    FROM  `TweetFollowers` f, Tweets t
    WHERE  t.`Poster` = '2554'
      AND  `Post` != ''
    ORDER BY  `Posted` DESC
    LIMIT  5
)
ORDER BY Posted DESC
LIMIT 5;

To assist in analyzing slow SELECTs, please provide
* SHOW CREATE TABLE tbl\G -- Which table has Post and Posted?? Indexes?
* SHOW TABLE STATUS LIKE 'tbl'\G -- sizes
* EXPLAIN SELECT ...\G -- run on your query and mine.
and surround them with [ code ] and [ / code ]

Options: ReplyQuote


Subject
Views
Written By
Posted
3029
May 18, 2009 04:36PM
Re: Need help :-(
2195
May 19, 2009 11:24PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.