开发者

Should i cache the whole query in php or should i just cache the primary key of the row?

开发者 https://www.devze.com 2023-04-07 09:38 出处:网络
The question is quite straightforward. I can\'t choose between either. In the dev documents MySQL has specified that indexes can pick a row from it\'s position rather than searching the whole table.

The question is quite straightforward. I can't choose between either. In the dev documents MySQL has specified that indexes can pick a row from it's position rather than searching the whole table.

Suppost i have a 开发者_如何转开发request to fetch the 20 best posts in my Posts table based on the ratings. Should i just cache the id's of the retrieved Posts or Should i cache the whole results for responding further requests.

Btw i'm using file based caching.


Memory is cheap and caching 20 rows usually don't take up much.

I would say: Cache the full rows if it isn't data that have a requirement to be fresh.


Rule of caching - cache data which has high probability of usage. In this case the probability is high so do cache them !

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号