|
 |
pro_php thread: MySQL/PHP Peformance Question
Message #1 by "Bill" <bige88fan@c...> on Sun, 16 Feb 2003 00:11:04
|
|
> I have a relatively easy question. I am running a script for some of my
h> osted sites on my server, and I want to give them the ability to adjust
t> heir web template for which the script displays it's output on. So my
s> olution would be to let them store their web layout in the database so
t> hat they can update it dynamically through their control panel. So my
q> uestion is:
> Will this cause a performance problems when I have to fetch the data
from
t> he database, rather than including it from a file with PHP?
I store content in mysql. Basically I have a function along the lines of
insert($content_id) which fetches text and evals it. Since the text is
eval'ed it can contain php and so you can end up with a recursive call of
the insert() function nested as far down as you want. I did it as an
experiment and I thought the performance would be atrocious but it's
really not bad at all. The thing to do is make sure you only store text in
mysql and have your binaries stored and referenced the usual way. I seem
to remember that Rasmus once recommended against storing html content in
the db for philosophical reasons but I'm not quite clear what they are and
I believe most CMS will keep content there. No database is as efficient as
flat-file storage but I suspect that any noticeable bottle neck will occur
with the user's connection (haven't measured this, just a guess).
Another approach that I have found to be really useful is templates (I use
the phplib one). It seems a bit counterintuitive at first but being forced
to separate your code and content is a great way of refactoring and
creating reusable modules. In your case, you might find it a useful way of
controlling the balance of customisation/standardisation and it would also
be far more secure. You should avoid a template system which allows you to
use php in the template (this is really bad design) and you will need one
that has blocks. The ability to include sub-templates is v. useful as you
can then modularise your layout.
|
|
 |