PHP Instant Message API
Before worrying about performance, you should worry about security. You are vulnerable to SQL injection. Never put any variables directly into queries, use prepared statements instead. 

Other than that:


mysql_ is deprecated for quite a while, and it will be removed in future PHP versions. You really shouldn't write code using it, use PDO or mysqli_ instead (and as said, with prepared statements).
upper-case all SQL keywords in your queries to improve readability.
your indentation is inconsistent.
your query seems a bit off. Do you really need union? Shouldn't something like WHERE (sender_id = '$sender_id' AND receive_id = '$receive_id') OR (sender_id = '$receive_id' AND receive_id = '$sender_id') work? 
I would change the date and time columns to a datetime column, it should speed up your query a bit.
receive should be receiver to fit in with sender.