Hello Pavel,

There's an accepted ticket about CREATE INDEX CONCURRENTLY: 
https://code.djangoproject.com/ticket/21039. A concrete proposal for adding 
this feature to Django would be interesting.

I'm not really sure about your two other suggestions. If you think they're 
improving the PostgreSQL backend, you're welcome to create a ticket and propose 
a pull request.

Keep in mind backwards-compatibility if changes are improvements in your use 
case but perhaps not for everyone else. For example, it may be better that 
index creating remain an atomic operation (so, not concurrent) by default.

Best regards,

-- 
Aymeric.



> On 26 Sep 2018, at 07:41, pavel.tysla...@gmail.com wrote:
> 
> Hi,
> 
> I found that django migrations don't designed for live updates on large 
> tables for postgres, eg. index creation doesn't use concurrently or alter 
> table operation can take ACCESS EXCLUSIVE lock for long time.
> 
> Before I mostly wrote custom migrations, but after one of downtime I decided 
> to avoid most common cases at all and wrote postgres backend that helps me in 
> it: https://github.com/tbicr/django-pg-zero-downtime-migrations 
> <https://github.com/tbicr/django-pg-zero-downtime-migrations>. When I wrote 
> it I found that it's a pretty easy extend core postgres backend, but a few 
> things required rewrite on my side:
> 
> - 
> https://github.com/django/django/blob/master/django/db/backends/base/schema.py#L152
>  
> <https://github.com/django/django/blob/master/django/db/backends/base/schema.py#L152>
>  used both for table columns creation and altering table add column, but not 
> null constraint and index constraints can't be changed without whole method 
> rewriting
> - for one core sql statement I found more "safe" equivalent with two sql 
> statements, but it's a bit hard to execute it, for example more save create 
> invalid constraint and than validate it or create concurrently index and than 
> create unique constraint
> 
> also I found that not all constraint names quoted in generated sql, for 
> example add_unique_together got `ALTER TABLE "table_name" ADD CONSTRAINT 
> table_name_f1_f2_hash_uniq UNIQUE ("f1", "f2")`, but expected `ALTER TABLE 
> "table_name" ADD CONSTRAINT "table_name_f1_f2_hash_uniq" UNIQUE ("f1", "f2")`
> 
> So I just curious is anybody interested to make django migrations more 
> reliable for large tables in prod or interested in some improvements 
> highlighted above, that can simplify writing backends for this purpose?
> 
> I also will be appreciated if somebody can share another solutions for this 
> purpose.
> 
> Paveł
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-developers+unsubscr...@googlegroups.com 
> <mailto:django-developers+unsubscr...@googlegroups.com>.
> To post to this group, send email to django-developers@googlegroups.com 
> <mailto:django-developers@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-developers 
> <https://groups.google.com/group/django-developers>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/421f001b-ca11-42bf-8735-0c6947b41988%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-developers/421f001b-ca11-42bf-8735-0c6947b41988%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/713CE15A-026A-4CE9-A70E-4D7C8884D79A%40polytechnique.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to