问题
is there a noticeable speed performance difference when you cache the data which you retrieve from the database to a file on the filesystem (eg.: htdocs/cache/cachefile) rather than grabbing it directy from the MySQL DB?
Thanks a lot!
回答1:
This highly depends on your disk IO, the size of your database, the database configuration, the link to your database, the optimization of the database, etc, etc. So there is no definitive answer to that.
You might want to consider memcached for your caching problem you have. Since you provided no information about the actual issue i'm in doubt you'll get good answers to resolve your problem. Or do you just want to know if disk-io is faster than mysql? ;-)
回答2:
Yes. What you are describing is a common method of speeding up web applications.
回答3:
The noticeable speedup question does also depend on the types of queries and frequency. If it is a once-a-day query, probably not so much. If it is the same query over and over again then probably more so.
回答4:
If you want to use the database just for caching mysql memory tables might be a good alternative. This should give you the benefits of an sql database without having to use the harddisk. If you don't need a sql-database in general memcached is a great solution.
来源:https://stackoverflow.com/questions/1433243/caching-question-mysql-or-filesystem