django-redshift-backend icon indicating copy to clipboard operation
django-redshift-backend copied to clipboard

should we disable server side cursor for redshift connection by default?

Open shimizukawa opened this issue 7 years ago • 6 comments

PostgreSQL driver use server side cursor by default since django-1.11. https://docs.djangoproject.com/en/1.11/ref/databases/#server-side-cursors

Should we set DISABLE_SERVER_SIDE_CURSORS = True ?

shimizukawa avatar Jun 30 '17 11:06 shimizukawa

@shimizukawa What is the downside of having server-side cursors on Redshift? It has a serious advantage for large querysets on PostgreSQL.

emyller avatar Aug 27 '17 17:08 emyller

@emyller Redshift documentation recommends against using sever side cursors. https://docs.aws.amazon.com/redshift/latest/dg/declare.html#declare-performance https://docs.aws.amazon.com/redshift/latest/dg/declare.html#declare-constraints

Cerebro92 avatar Oct 10 '18 12:10 Cerebro92

For what it's worth, not really sure....

I just started working on a dashboard for a redshift project and am prototyping with rails and django. The DISABLE_SERVER_SIDE_CURSORS = True setting got me past a “cursor ”django_curs*" does not exist” error.

I was getting that error on a ForeignKey association in admin and in a filtered list view I was building

techbrownbags avatar Apr 03 '19 14:04 techbrownbags

me again, even with DISABLE_SERVER_SIDE_CURSORS = True i'm seeing the exception in django_admin for a model with a site = models.ForeignKey(Site..) when navigating to the edit page.

I am setting the PK and FK in the redshift schema for documentation and query optimization.

Is anyone else seeing this?

techbrownbags avatar Apr 09 '19 22:04 techbrownbags

I just ran into this issue which setting DISABLE_SERVER_SIDE_CURSORS = True resolved:

I received the following error when rendering a bound form (i.e. re-displaying a populated form) that had a ModelMultipleChoiceField pointing to a model utilizing Redshift (note that an unbound, blank form rendered with no issue):

cursors can only be used within the transaction that created them

Strangely, googling that quoted phrase returns no results which made troubleshooting difficult. This error is thrown during the handling of the above exception while trying to close the cursor:

OperationalError: cursor "_django_curs_140089065723648_1" does not exist

I'm not using the admin for any of my models in Redshift, but I tried registering and testing one and it seemed to work okay regardless of the setting of DISABLE_SERVER_SIDE_CURSORS.

piranhaphish avatar Apr 12 '19 22:04 piranhaphish

DISABLE_SERVER_SIDE_CURSORS does work, as you know. I started having the issues when I added another db connection and had to move that setting to the specific redshift connection. Thanks

techbrownbags avatar Apr 25 '19 19:04 techbrownbags