Created
August 8, 2012 20:33
-
-
Save dcramer/3298424 to your computer and use it in GitHub Desktop.
Server side cursors in Django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1: Connection method | |
with connections['default'].sscursor(): | |
Foo.objects.all() | |
^^ this sucks because we make assumptions about where Foo routes | |
#2: QuerySet method | |
Foo.objects.all().sscursor() | |
^^ kind of sucks as it extends QuerySet with a dumb method name | |
#3: Generic Wrapper (ala crappy transaction management, but better) | |
with SSCursor(): | |
Foo.objects.all() | |
^^ Kind of painful to implement, especially with thread-safety since it has to manage | |
all connections | |
#4: Another QuerySet method | |
Foo.objects.all().options(server_side_cursor=True) | |
So far #2 is winning |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment