Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql Table Partitioning Django Project

I have a Django 1.7 project that uses Postgres 9.3. I have a table that will have rather high volume. The table will have anywhere from 13million to 40million new rows a month.

I would like to know what the best way to incorporate Postgres table partitioning with Django?

like image 497
arcane Avatar asked Jun 01 '15 00:06

arcane


People also ask

Does PostgreSQL support table partitioning?

PostgreSQL supports basic table partitioning. This section describes why and how to implement partitioning as part of your database design.

How do I partition an existing table in PostgreSQL?

You can use the ALTER TABLE… ADD PARTITION statement to add a partition to a table with a DEFAULT rule as long as there are no conflicting values between existing rows in the table and the values of the partition to be added.

Does Postgres create partition automatically?

Table partitioning is one of the best-liked features out of the more recent PostgreSQL developments. However, there is no support for automatic partition creation yet.


2 Answers

If you are using newer version of PostgreSQL, you can try this

https://github.com/chaitin/django-pg-timepart

A Django extension that implements PostgreSQL tables for partitioning and management based on dates.

like image 121
virusdefender Avatar answered Oct 12 '22 02:10

virusdefender


You can use Architect application for Postgresql Table Partitioning Django Project

PostgreSQL’s partitioning implementation in Architect is done purely at the database level. That means that Architect creates several triggers and functions and inserts them directly into the database, so even if you issue direct insert statement from database console and not from the ORM, everything will work as expected and record will be inserted into the correct partition, if partition doesn’t exist, it will be created for you automatically. Also partitions may be created in any order and not only from lower to higher.

It's new version of old Django DB Parti application

like image 30
ramusus Avatar answered Oct 12 '22 02:10

ramusus