You are here: Re: [PHP] Which is faster, a MySQL access, or a set of PHP variables? « PHP « IT news, forums, messages
Re: [PHP] Which is faster, a MySQL access, or a set of PHP variables?

Posted by "Richard Lynch" on 12/30/05 20:26

On Fri, December 30, 2005 8:32 am, Dave M G wrote:
> I wondered if there was any downside to storing the list of interface
> texts in a MySQL database, then calling them as an array when the page
> loads?

If you are already connecting to the database, then you are comparing
an extra query or two to loading a file from the hard drive and the
database wins on performance.

Unless you are already loading some file where it would be convenient
to stick the text, and then the variables win.

Actually, this all depends on your hardware and database/drive
performance setup...

There really is NOT a good answer to this question from a
"performance" stand-point.

But then it's not a good question, really, unless you REALLY expect
your site to get a ton of traffic, because the performance of the
machine will probably not be a big factor in your success, compared to
maintainability of code, feature-set of the site, cool-ness and
prettiness and marketing and... All of those will matter more to your
success than raw performance.

> This would have one minor advantage, which is that as I expand to new
> languages, I could build a simple web interface where people could
> input
> new languages into a form.

Something to consider:

Can you get data in other character sets into and out of your database
and web application?

If you plan to support 2-byte (or more) character sets, this is not
trivial at all -- or maybe it is, but you have to at least plan ahead
for it from the get-go.

> However, is it a drag on a server to have to reach into the MySQL
> database to retrieve the array of texts each time the page loads? Note
> that the texts will be something like 20 to 30 small one to four word
> phrases like "contact" and "previous page" and that sort of thing.
>
> On the surface, it doesn't seem like this would be much different
> than
> accessing a PHP script with a list of variables. But then, I figured
> there might be a reason why I've never seen it done this way.

Generally, on most projects, the people who are contributing the
translations of internal things like "contact" and "previous page" are
developers who are comfy with editing a text file, and putting them in
as text files with, say CVS or subversion, gives the developers
control over versioning etc.

That's not to say you COULDN'T do something similar with the database,
or run hourly dumps of (some) tables into CVS or something.

I don't think it's going to matter much which way you do this, so long
as you can plan ahead for all the character-encodings you will ever
need, and make sure you can handle them all.

Perhaps try it with a test phrase like "Hello" which you can probably
find in every language fairly easily.

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация