On Aug 19, 9:03 pm, Russell Keith-Magee <russ...@keith-magee.com>
wrote:

> As for the instance not existing: Consider the following queries:
>
> MyModel.objects.filter(foo=bar)
>
> or
>
> MyModel.objects.update(foo=bar)
>
> These are read and write queries respectively, but neither has any
> meaningful concept of a current "instance".

OK, now I see the issue.

I'd need to do queries like this one:

Tweet.objects.filter(author_id=123)

Now like you said there isn't any current instance to speak of.
However since I'm retrieving tweets from a specific author it is very
clear which shard this query should go to as tweets are sharded by
author_id.

So is there any way to write the database router to route the above
query?


> If you think that Django isn't providing
> sufficient information to implement a specific routing scheme, make
> your case and we will see about adding whatever extra information may
> be required.

The issue with using only "instance" as a hint is that in almost all
cases of database reads there isn't any instance to speak of at the
time the query is being issued. After all the very purpose of a
database read is to retrieve the instance!

The above example of:
Tweet.objects.filter(author_id=123)
represents pretty much the most common scenario for database sharding.
I'd think it's important for Django's multidatabase function to be
able to handle a case like that.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to