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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -