How can I improve this DB query? it takes too much time
Even though you didn't post table definitions in your question so I can't tell for sure what is missed, the following indexes will be beneficial  :


Index on table (user_id, created_at)
Index on users(id_str) or even users(id_str,screen_name,profile_image_url)
I guess you already have an index on table(id) 


UPDATE

Change WHERE :
from WHERE UNIX_TIMESTAMP(t.created_at) &gt; {$today}  to WHERE t.created_at &gt; FROM_UNIXTIME({$today}), this way optimizer will use index that includes create_at column more efficiently.