views:

102

answers:

4

Hi,

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!

A: 

Yes. What you are describing is a common method of speeding up web applications.

Mike Buckbee
A: 

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? ;-)

Malax
Hi Malax,yes exactly, just wanted to know if the disk is faster than MySQL,i would say that theres no noticeable difference because everything is stored on the disk, besides the DB is on an different server...I know memcached but its not an option for me because i'm on an shared host :\
460128900
Then you get the "it depends" answer. If you have, for instance, a complex tree of data, generated from SQL queries it might be a lot faster to cache the tree on disk instead of building the tree on each request. You also could cache generated HTML snippets... but im in doubt that a simple "SELECT name FROM users WHERE id = 23" would be slower than reading the name of the user with id 23 from disk... but... it depends. ;-)
Malax
Ok thanks, got that :)that was really quick, i think, i love stackoverflow :)
460128900
A: 

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.

Deverill
A: 

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.

Mobbit