4 ms·
The original plan was to add higher level support for certain types of sharding (e.g. tying a specific model to an individual database) and earlier versions of
by simonw 17y ago
The original plan was to add higher level support for certain types of sharding (e.g. tying a specific model to an individual database) and earlier versions of the code actually provided a method for doing so. This was removed because it wasn't judged to be a good enough solution - Django is very keen on the concept of reusable applications, and hard coding a decision of which database should be used for an application's models in to that application would conflict with that concept.
Obviously the solution is to specify a mapping somewhere, but there's no need to hold up the feature while waiting for a design for that particular bikeshed.
Instead, the plan is to release an initial version with low level primitives: the ability to configure multiple databases and specify which database should be used for a given query. This gives us a chance to see what kind of patterns are most widely used and figure out the correct way to support those at a higher level of the API.
In my opinion, the SQLAlchemy example demonstrates why handling sharding automatically is a distinctly non-trivial problem: http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/examples/sharding/attribute_shard.py#L129 http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/exam... - it's not clear to me that that's a better solution than just manually picking the database to execute a query on at the point of execution.
- moe 17y agoWell, SA provides all the primitives required for setting proper sharding up - admittedly it could use some more documentation and an out-of-the-box anonymous sharding lib. The example is fully functional, though, and once you've wrapped your head around it, it all makes sense and does indeed work (I've used it in production). Sorry, but "seeing what patterns are most widely used" is a lame excuse. You could just look at what real world sites do today (and did 4 years ago) - or simply jump right to implementing the only anonymous sharding model that can possibly work (see how mongodb does it). I'm not meaning to bash django as a whole here, but I had a true WTF-moment looking at that page. It seems the home-grown ORM is becoming a ball on a chain if something like that takes this long... Anyways, at least it's progress in the right direction, looking forward to real partitioning support, hopefully in earlier than another 4 years.