Suppose we have multiple sites (using sites-framework of Django) running on the same django instance.
MyModel.objects.filter(site_id=request.site, slug=slug)[0]
might be an overhead in the future. So I was wondering if I could split the databases for this model(s) for querying faster.
So if request.site
is 1, running
MyModel.objects.get(slug=slug)
will query only db1.
If request.site
is 2, running
MyModel.objects.get(slug=slug)
will query only db2.
I will be getting request.site from the request parameter of the view as value of site will be dynamically determined according to the subdomain used: de, fr, etc.
You may create a custom router to do this:
Example:
You can readup more here https://docs.djangoproject.com/en/dev/topics/db/multi-db/