GithubHelp home page GithubHelp logo

Querysets joins about django-balancer HOT 5 OPEN

michaelhelmick avatar michaelhelmick commented on June 12, 2024
Querysets joins

from django-balancer.

Comments (5)

bkonkle avatar bkonkle commented on June 12, 2024

This is definitely an interesting problem, and it's something I want to spend more time thinking about. It makes sense to me to simply pin all the queries from a single request to one database, but I'd like to test it out and see what kind of side effects this would introduce. In the meantime, you may need to adjust your code to work around this limitation.

from django-balancer.

sebzur avatar sebzur commented on June 12, 2024

Thank You for this fast comment! Pinning all the queries from a single request to one DB I also find out (at least as a first thought) to be a reasonable solution.

I hope You will find some time to provide the additional router to handle the issue - I can't wait to test it!

from django-balancer.

bkonkle avatar bkonkle commented on June 12, 2024

I've finished a first pass at this feature, but I don't have an active project right now that I can do some real testing with. Can you test it out and let me know what you think?

Checkout the "feature/request-pinning" branch and set REQUEST_PINNING to True in your settings.py.

Thanks!

from django-balancer.

wolph avatar wolph commented on June 12, 2024

Since you usually want to spread the load as much as possible, I would vote against pinning within a transaction unless really needed (i.e. with writes and replication lag).

In this case I would go for a solution where you get a database from the router (i.e. db = db_for_read(Person)) and do a young_people, old_people = young_people.using(db), old_people.using(db) to use the same database for this specific case.

from django-balancer.

sebzur avatar sebzur commented on June 12, 2024

Okay, that's good to see that. I'll try to switch from pgpool to the django-router and test this update. Thanks a lot for Your time!

Of course, specifying the common db with .using in queryset is a solution that one should use for the merges. However, in my rather big project I'll have to localize all occurrences of these and switch them.

The update that bkonkle have entered handles the cases before the switch.

I'll give You the info how it works soon.

from django-balancer.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.