title: Is a good practice to send ajax post every 1 second to check database modifications?
body: <p>I need to check if there's some modification in a specific status in database. To do it real time, I want to send an Ajax Post every 1 second to check in the MySQL database if has some modification.</p>
  
  <p>But I have doubts about the performance. The page will probably stay open for hours. Then I don't know if is a good idea to do, every second, a "SELECT QUERY" in database.</p>
  
  <p>Someone knows if there's some problem stay a page opened for hours, sending ajax post every second, checking MySQL database (Select Query) and changing the page with the result (when status modified)?</p>
  
  <p>PS: (1) There's not possible to use websocket. (2) I'm using PHP and MySQL. (3) The server is Windows running XAMPP.</p>
  
  <p>The code is (it works):</p>
  
  <pre><code>function status_check(){
      var AJAX_URL = $('#AJAX_URL').val();
      setTimeout(function(){
          var body = $('body');
          var ss = body.attr('data-step');
          var formData = {
              ss: ss,
              a: 'cn'
          }
  
          $.ajax({
              type: 'POST',
              url: AJAX_URL,
              data: formData,
              dataType: "json",
              success: function(data){
                  // change the HTML with the returned data if has modification
              },
              error: function(xhr, status, thrown){
                  console.log(xhr);
              }
          });
  
          status_check();
      }, 1000);
  }
  
  $(document).ready(function(){
    status_check();
  });
  </code></pre>