Skip to content

Commit 76ff036

Browse files
author
Konstantin Podshumok
committed
update docs
1 parent a92dd30 commit 76ff036

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

README.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,22 @@ If you have multiple DB configuration, Django will call this hook with DB-alias
1414

1515
Partitioning is currently implemented only for PostgreSQL. Use `db_index` parameter in the fields of your models to automatically create indexes on partitions.
1616

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+
class MyModel(Model):
24+
#...
25+
@to_partition
26+
def save(self, *args, **kwargs):
27+
#...
28+
super(self.__class__, self).save(*args, **kwargs)
29+
```
30+
1731
Drawbacks:
1832

1933
* 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

Comments
 (0)