Skip to main content

A Django app to automatically handle sharding model tables in MySQL.

Project description

Django table sharding is an app that will allow you to shard your database tables in the same database using a shard key or shard suffix.

Detailed documentation is in the “docs” directory.

Quick start

  1. Add “django_table_sharding” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'django_table_sharding',
    ]

Every time migrations are run it will copy changes from the source table to the sharded tables.

Set the model manager to the models you want to shard into their own tables. Example:

objects = ShardManager()

The migration process will automatically find all sharded models and apply the new migrations.

Sharded models can have ForeignKeys, but other models cannot foreign key to the sharded models because original table is not used.

Sharded models cannot contain OneToOneField, or ManyToManyField, for same reason.

When running migrations the normal migration will run as normal, and then changes to source table, will be applied to all shards in the database.

Before deploying to production please make sure everything fits your needs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-table-sharding-1.0.3.tar.gz (15.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page