Page 1 of 1

require versus db select: speed difference

Posted: Fri May 30, 2008 4:09 am
by koen.h
A database request is essentially reading from disk. So is including a file. Anyone knows which is faster? I assume require but require_once is very slow too.

Re: require versus db select: speed difference

Posted: Fri May 30, 2008 4:48 am
by Eran
It depends. Databases use all sorts of query optimizations and keep a cache in memory. If there is a cache hit, loading from database is probably faster (no need to load from disk) - so if you request the same resource a lot, you might get better performance that way.
You should probably profile both cases if performance is important.