mardi 19 janvier 2016

SQL & Website - how to optimaze website

I want to add some statistic - how many messages user send to other users. Now, user is going to his panel and sees that number. Should I execute

SELECT count(*) from MESSAGES where id=user.id

every user panel page is refreshed? Wouldn't it kill my DB? For exmaple 1k users refreshing account page, and in addition few pranksters who will spammingly pres F5?

I have similar problem with retrieving games played by user, last login date etc. I'm wondering is it a good idea to execute sql every time or maybe i should cache this values in local.storage and increment them every time I do update on DB value? And if user logging off then clear local storage.

What do you think?




Aucun commentaire:

Enregistrer un commentaire