Re: Which is faster, a MySQL access, or a set of PHP variables?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux