title: PHP/MySQL/jQuery (admin-users) chat
body: <p>I am writing a users-admin chat system (with logged users) where an admin must detect online users. I don't have any experience with this sort of system and I need your advice.</p>
  
  <p>I have created following tables:</p>
  
  <pre><code>users (user_id, last_active, login, password)
  chat (chat_id, user_id, read, dir, msg, posted_on)
  history (history_id, user_id, dir, msg, posted_on)
  </code></pre>
  
  <p>Every 7 seconds I am doing an asynchronous request with jQuery or sending a message and every time on the server side I do the following operations:</p>
  
  <pre><code>if(isset($_POST['msg_send'])){
  
  //check admin(user) online statuse:if admin(user) online insert msg to chat and history.
  
  if admin(user) isn't online, echo "admin not online"
     return;
  }
  
  //get message from chat ;
  //update chat_table;
  </code></pre>
  
  <p>I am wondering: if I perform this operation for every request, will it be a big hit performance-wise? If so, can you suggest another option?</p>