Not exactly. Django works equally well with all the databases we
support -- we wouldn't claim support for a database that didn't work
somehow. Nor is Django itself "opinionated" in this manner; neither
the software nor its developers give a hoot what database you use.
Engrave all your data in stone tablets; doesn't bother me!
That said, many of the Django core developers -- me included -- do
prefer Postgres for our own work. Its emphasis on data integrity and
SQL standards along with the radically open development model I think
appeal to our feelings about software design and Open Source.
Jacob
I think the "preference" comes from "that's what we happen to be
using, so we may be be better equipped to answer questions you
might have" as there seems to be a recommendation in the 0.96 docs
http://www.djangoproject.com/documentation/0.96/install/
but that preference has been removed in the current docs
http://www.djangoproject.com/documentation/install/
I can't speak for the authors of the documentation, but I've
found that PostgreSQL is generally more complete when it comes to
standards compliance, though I must say that MySQL has been
rapidly closing that gap. It used to be that MySQL lacked Views,
stored procedures, and my biggest pet-peeve, sub-selects (there
may have been some additional features I'm missing in this list).
Postgres also has greater support for GIS info if that's
important to you.
MySQL did have native full-text and replication features before
Postgres (which had them as add-on modules, but not natively).
Postgres has taken a path of "get it correct & complete, then
optimize" while MySQL seems to have taken the path of "get it
fast and then fill in the missing features".
The last shoot-out I saw, MySQL performed better under light to
modest load (especially with read-only queries), but started
choking at higher sustained load, while Postgres was a tiny bit
slower at low to medium volumes but just kept on truckin' at
higher sustained load. And Postgres is no slouch in the speed
department anyways.
These days, I find them fairly equal in functionality -- MySQL
has added support for most of the missing elements, and Postgres
has added support for full-text and native replication. Speed is
also pretty comparable these days. I personally find MySQL a
little easier to administer but that's my own experience.
Additionally, you're often more likely to find MySQL on most
hosting company servers. But if you're building your own server,
then you can install whatever you like.
-tim
Postgresql is where you'll end up going for performance when you
approach larger sites. It can compete with Oracle in situations MySQL
cannot.
This is off the top of my head, so I don't have any numbers or
anything, but thats what I've come to understand.
Lets be clear here - the problem you are describing is fundamentally
MySQL's problem, not Django's. MySQL doesn't interpret the standard
right, and doesn't provide for an easy workaround. There isn't much
Django can do in this case. This is an example of what Tim was talking
about - MySQL is still adding features and fixing problems with their
SQL implementation.
If you choose a piece of infrastructure, you have to accept the
limitations of that infrastructure. Any database backend will have
strengths and weaknesses; the fixture loading problem is one of
MySQL's limitations.
> Of course, it quickly becomes obvious that editing the output of
> dumpdata is a bear with any significant amount of data or an app of
> any complexity. As there is no way to specify the order of tables for
> dumpdata, and apparently dumpdata doesn't attempt to dump referenced
> tables first, this is quite a problem for MySQL users.
Ordering tables is a partial solution, but it won't work in the
general case. However, something would be better than nothing, and
there is something to be said for making serialized output ordered for
purely aesthetic reasons.
If someone (cough cough... hint hint) were to submit a patch to
implement table ordering on serialized output, I'd have no problem
committing such a patch.
> Speaking of
> evolving, django-evolution has many issues with MySQL versus
> postgress. I've therfore decided to bite the bullet and switch to
> postgres...
(for those not aware - I'm a core developer of Django Evolution. These
next comments are from me wearing my Evolution core developer hat)
Django Evolution is a slightly different beast - Django Evolution
isn't part of the core Django project, and if you read the FAQ, I
don't make the claim that MySQL is equally supported under Django
Evolution - in fact, I clearly state that MySQL is a work in progress,
simply due to my personal priorities. I have also said on many
occasions that I would like to fix this situation, but I am only one
man, and I only have so much time to give.
I will gladly accept any patch to Django Evolution that improves MySQL
support (and I have done so on a number of occasions in the recent
past).
> In short, I don't think it is fair to say that Django supports all db
> backends equally. I wish that early on, when choosing Django, I had
> been led definitively down the postgres path.
If a bug is found in Django's MySQL, we are committed to fixing it (if
it can be fixed). The ticket just needs to work through the triage
process. There is only 1 ticket in the "Ready for Checkin" list that
is MySQL specific, and I'm not completely convinced it's the right
solution. If MySQL were a non-supported platform, this list would be
longer.
Yours,
Russ Magee %-)
Hmm...that would explain the bug I'm getting in Evolution:
Traceback (most recent call last):
File "testevolution.py", line 42, in exercise:
OutOfRussMageeError: Insufficient Russ Magee's; please
contribute patches and try again.
:-)
-tim
No problems. In the spirit of reconciliation, I didn't intend to be
harsh either - I just wanted remove any doubt that MySQL is a first
class citizen from the point of view of the Django core developers.
>> If someone (cough cough... hint hint) were to submit a patch to
>> implement table ordering on serialized output, I'd have no problem
>> committing such a patch.
>
> Hmm.... hint taken. I'll start to look at it in my "spare time"...
> maybe things will cool down at work in a month or two (seriously, I'm
> swamped right now). In the mean time, should I submit a ticket?
Already logged: http://code.djangoproject.com/ticket/3615
There's a patch already on that ticket, and it works, but the solution
provided isn't ideal. The problem with the patch is that when foreign
key checks are turned on again, there is not validation of data
inserted when they were off. It's more of a workaround than a
solution.
Yours,
Russ Magee %-)
> Absolutely. I am not pointing fingers, but throwing my two cents into
> the answer to "Why PostgresSQL?" I think, given the current state of
> MySQL, the problems I outlined are very strong arguments for using
> postgres instead of mysql when choosing Django.
I have exactly the same experience.
IMHO, if you don't have a *very* good reason to choose MySQL, do *not*
choose it, otherwise you will run into problems, especially if a
schema evolution/migration is a significant task for you...
> when I first made the Django choice, that I had made the jump to
> postgres then.
Unfortunatelly, we use Django application as a configuring/monitoring
web based tool for large back-office application using MySQL as shared
database, hence we cannot move PostgreSQL easily...
Peter
Yes - I added that link last night. Ticket #3615 came up in a separate
discussion yesterday, and someone suggested that script as a possible
solution. If someone wants to go to the effort of integrating that
script (and the license allows) I'd be happy to commit such a fix.
Yours
Russ Magee %-)
AFAICT, that's the same idea suggested on #3615. The discussion on
that ticket describes why it's not the final solution.
Yours,
Russ Magee %-)
The problem is that the cost of being wrong is so high. I might be
absolutely sure that I don't have any problems in my data, but I could
be wrong. If I'm right, there's no problem, but if I'm wrong, I can
get the database into an invalid state, and the first time I'll know
about it is when everything goes to hell because I try to follow an
invalid reference.
> As for ordering the tables in the dumpfile: I agree that it might not
> be a general solution, as couldn't there be cycles in the foreign
> keys? Or is that not allowed?
Cycles are certainly both possible and allowed. Hence the problems
with finding a general solution based on model ordering.
> Anyway, it's certainly a better quickfix for AmanKow's situation than
> editing the dumpfile and rearranging the order of tables.
Completely aside from the 'it might help some MySQL fixture loading"
angle, there's a cosmetic angle - at the moment, fixtures are dumped
in dictionary order - which is to say, no order at all. Sorting
fixture output (both by model, and internally by key) would make the
dumped output much nicer to spelunk through manually.
Yours,
Russ Magee %-)