It's not just the need for reliability that will make a database engine
large. They also have many facilities such as for value
checking/vetting, table joins, SQL parsing and optimising, different
access methods etc. And each new version of a database accretes
additional code for new features.
As you say, there will be good reasons for the size of the code but very
little of it will be used in most cases. To make an analogy you don't
need a copy of the OED if you just want to look up normal words. You
don't say that the OED is that large for a reason and therefore it is
the one to use.
I haven't timed the traditional access process but consider these steps
1. Get an authenticated connection. DB checks credentials
2. Send a query string. (Let's assume that the string already has fields
filled in.) DB parses the query string checking that it is well formed
and that the tables mentioned therein are valid. DB (hopefully)
generates an optimised form of the search query by looking at
information about the tables mentioned: whether they have an index, what
fields are indexed, and how many records are in the table.
3. DB runs the query by accessing files and forms a reply object which
contains the rows in some form for which the fields are accessible.
4. PHP takes the DB reply and converts it to a PHP object, along with
making sure that the fields of a row are accessible by key or index or
whatever.
5. The requesting code checks the reply object and accesses the content
therein.
The above is fine for large datasets. But sometimes what I want to do is
access a piece of stored data by a simple key. For that, the above is
overkill.
By contrast, to get the same piece of data from a flat file I would just
access a file (a simplified form of step 3 of the above).
Perhaps the issue is not just the size of the engine but that MySQL and
its ilk are based on tables whereas what is sometimes wanted is a simple
key-value store. (The stored values could be scalars or tables or even
tables modified by query strings which select certain columns and rows.)
> I looked at the ones J.O. pointed out, and I see nothing that will
> prevent data corruption by such things as concurrent updates from
> multiple applications. Now maybe that's not important to you, but it is
> to anyone who cares about their site it should be. Plus, I still don't
> see any performance comparisons for them - but they are going to be much
> slower than any SQL database written in a compiled language.
From their descriptions I too am not sure that any are suitable
(although having them pointed out was welcome).
> As for your hosting provider not providing one - a total red herring.
> You have to depend on the hosting provider for a lot of things - the web
> server, PHP and other things. Plus, every hosting provider has a SQL
> engine nowadays - MySQL is the most common.
Yes, that's probably valid.
> And I don't know of anyone who limits query rates - at least not amongst
> the non-free companies. And the query rate of your PHP database is
> probably going to be slower than that set by even the free hosting
> companies. Plus, if you do have a hosting company who limits the query
> rate, it's going to be to limit the load on the server - and your PHP
> database is going to load the server more than a real database engine does.
If you want to set up a site for a special-interest group you might find
that no one wants to pay a subscription to keep the site going. In that
case a free hosting solution is ideal but you have to work with the
limitations of the provider.
That said, those limitations are not very onerous. I found one which had
PHP and MySQL as normal and also allowed URL rewriting which was a
distinct benefit. But they had/have a limit on DB queries per second. I
don't know the sanction if you exceed the limit but they may require an
upgrade to a paid service which would effectively kill the site.
> Is the security model important? Do these even have a security model?
> If you are concerned about security, you should be looking for an engine
> which stores the data outside of user space where it's safe; if you can
> access the files themselves, then others potentially can, also.
Well, the problem I mentioned before was having to use the site's
password to access the database - even for data that did not need to be
secured. The security flaw there was having to use a password in the
code or something accessed therefrom.
> But now we get down to the real reason - you think it will make your
> replication easier. Replicating a database is not hard; on my sites I
> do it automatically once a day for backup. It's a one line command for
> each database (I could back up all of them in one line but restoring a
> single database would be harder). And if I have to restore a database,
> again, one line. Not hard at all.
I don't know why you would think this is the "real" reason. Are you some
sort of mind reader? *All* the reasons I gave were valid and relevant.
James