samedi 16 septembre 2017

repeated mysql fetch results in high resources usage on php

In my Php page i used repeated checks for new updates/insert using Ajax that results in high resource usage.One code i used for notification as follows.

$sql = "SELECT * FROM Notification WHERE user_id='$_GET[user_id]'";
  $count=mysqli_query($conn, $sql);  
  $cnt=mysqli_query($conn, $count);                                   
  $ct=mysqli_num_rows($cnt);

Similar mysql fetch used in chatting page results in server error. How can i avoid regular check and get data when the new data inserted or updated in db.




Aucun commentaire:

Enregistrer un commentaire