Answer the question
In order to leave comments, you need to log in
Mysql fetch or cookie optimization?
this is probably a very stupid question, but still:
for example, there is a page, 10,000 unique visits per day, a database of ~ 50,000 rows, which option is better -
1) mysql fetching the user only once, then all the data is set in cookies, after which on the next page reloads, a check is made for the existence of cookies and data is retrieved from it (or if not, then also a connection to the database, fetching, transferring data to cookies, and so on)
2) every time the page is reloaded, always mysql fetching
as if logically, the first option seems obvious, so as not to once again load with a selection of 50k rows, but why I ask - because once someone said that "jumping from mysql to cookies is bad", maybe I misunderstood the person , maybe he me, but still. (+ I doubt it, because PHP also deals with cookies, also the load, but on the other hand, it’s minimal, it’s not 50k lines)
please put an end to my doubts once and for all
Answer the question
In order to leave comments, you need to log in
When your numbers are 1000 times higher and there is no money for a normal server, then your question will become relevant. With such numbers, the cache will not release server resources, they should be free anyway, so there is no point in the cache.
If with such numbers everything slows down for you, you need one of the following: change the architecture of the database or figure out how to work with the database or hire an admin.
Neither one nor the other option.
Use the cache, save the result of the selection in a file or somewhere in memcache / redis and take it from there a second time, this will give an advantage.
if the data is too simple, then save it in sessions (they are not fucking needed in cookies).
One way or another - try not to pull the base once again.
ps keep it as long as possible (or vice versa, with a large number of visitors, a cache of 1 minute will give a huge advantage)
50k rows is very little for a database. Vybrka, especially with indexes will happen mnogovenno.
You should start worrying about performance when the tables start to exceed millions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question