mysql - Select Query is very slow and sometime hangs my database -
i need on suggestion on how can make such query faster
select count(distinct tweet_id) count tweets tweet_id not in ( select distinct in_reply_to_status_id tweets_response created_at > date_sub(now(), interval 24 hour)) , created_at > date_sub(now(), interval 24 hour )
.
i have place indexes on tweet_id , created_at still slow
suspect issue indexes (and comments above on doing explain 100% correct), using subselect not necessary. query rewritten as:-
select count(distinct tweet_id) `count` tweets left outer join tweets_response on tweets.tweet_id = tweets_response.in_reply_to_status_id , tweets_response.created_at > date_sub(now(), interval 24 hour) tweets_response.in_reply_to_status_id null , tweets.created_at > date_sub(now(), interval 24 hour)
Comments
Post a Comment