home / django_tickets / tickets

tickets: 1142

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
1142 2005-12-30 13:24:40 2009-12-22 20:39:52 2022-03-06 03:22:34.331929 Accepted closed Database layer (models, ORM) enhancement normal   fixed Support for multiple database connections Django currently assumes that all models will be stored in a single database, and that only one database connection will be used for the duration of a request. This assumption does not scale to really large applications, where it is common for multiple database connections to be used in non-obvious ways. Three examples include: 1. Traditional replication, where all writes go to a single master database while reads are distributed across a number of slave databases. 2. Sharding, where (for example) user accounts 1-1000 live on db1, 1001-2000 live on db2 etc. 3. Different types of data live on different servers / clusters. Frequently accessed user profile data might be stored on a seperate database/cluster from log data which is frequently written but very rarely accessed. At the very least, Django needs to allow more than one database connection to be maintained by the DB wrapper. The default should still be a single connection as this is the common case, but Django should not get in the way should multiple connections be desired. Rather than having a single connection, how about maintaining a dictionary of connections? A "default" key could correspond to the connection that is used in most cases, but other connections can be configured in the settings file and assigned names. There would need to be a mechanism somewhere for Django model classes to be told which named connection they should use. Simple replication may end up being a different issue entirely - it's possible that could be handled just with a custom DB backend that knows to send writes to one server and distribute reads across several others. The above change (where Django allows multiple DB connections) is still essential for more complex configurations. More about this on the mailing list: http://groups.google.com/group/django-users/browse_thread/thread/d08f4975da831bb/75ede5e9c7f0db53 Alex Simon Willison multiple database feature 0 1 1 0 1 0
Powered by Datasette · Queries took 1.121ms