You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-1
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,22 @@ If you have multiple DB configuration, Django will call this hook with DB-alias
14
14
15
15
Partitioning is currently implemented only for PostgreSQL. Use `db_index` parameter in the fields of your models to automatically create indexes on partitions.
16
16
17
+
Apply `post_syncdb_hooks.partitioning.to_partition` decorator to `save()` method of models involved into partitioning:
18
+
19
+
```python
20
+
from post_syncdb_hooks.partitioning import to_partition
21
+
from django.db.models import Model
22
+
23
+
classMyModel(Model):
24
+
#...
25
+
@to_partition
26
+
defsave(self, *args, **kwargs):
27
+
#...
28
+
super(self.__class__, self).save(*args, **kwargs)
29
+
```
30
+
17
31
Drawbacks:
18
32
19
33
* Empty indexes on master-table;
20
-
* You need to run `manage.py syncdb` twice since Django create indexes after `post-syncdb` hook.
34
+
* Two queries per `INSERT INTO` instead of one in PostgreSQL;
35
+
* Need to run `manage.py syncdb` twice since Django create indexes after `post-syncdb` hook.
0 commit comments