PHP jQuery MySQL refesh instant

210 Views Asked by At

I have made a progress sheet that between 1-30 users will update constantly throughout the course of the day. It’s controlled by PHP and jQuery and all the data is stored in a mySql database.

It’s quite slow on the live server, because I re query on searches and filters. I was wondering where is the best place to store the result, because I only need the latest updates but I do not need to constantly filter and update.

Is it okay to store that kind of data in a session or who else could I store it to avoid full query on every change/search or when the page changes?

1

There are 1 best solutions below

0
On

I did look into memcached, but I ended up redesigning it.

I used jQuery to filter the records using hide() and show() on the data attributes that matched, instead of using a “LIKE '%Darren%'” SQL query. This puts the load on the user’s terminal opposed to my server (Try to keep the animations to a minimum, to keep the memory usage low).

Then I store a timestamp of the last update on the user’s terminal in the HTML then run a “SELECT id FROW progress WHERE updated > '2014-02-20 16:54:30' LIMIT 1” query periodically. If I get 1 record back I use Ajax to a full update and refresh the areas required with fresh HTML.

Doing it this way has made it so much quicker and smoother.

I how this helps, if you need more info let me know!